On 1/25/2012 11:42 PM, MB Software Solutions, LLC wrote:
> I'm dealing with very large datasets (millions of rows) and so my SQL
> needs to be "on" more than ever!  I'm using MySQL and I'm using EXPLAIN
> <sql>  to help me make sure my SQL is optimized.  I've got several
> fields, two of which are in my WHERE clause for several UPDATE SQLs.
> The EXPLAIN didn't work for UPDATE so I did it for a SELECT with my
> WHERE clause being the same as in the UPDATE SQL.  I thought if I had a
> compound index on the two fields (one being VARCHAR(10) and the other
> being CHAR(10)) that it would use that for best optimization (as opposed
> to a separate index on each field).  However, many of my UPDATE SQLs are
> like this:
>
> UPDATE MyTable SET MyFactor = 1.23456 WHERE Field1 = 'VALUE' AND Field2
> IN ("VALUE2","VALUE3")
>
> The EXPLAIN says it won't use the combined index.  But for simpler
> UPDATEs where it's just one value for Field2 and using an =, it says it
> WILL use the index.  For example, this SQL would utilize the compound
> index:
>
> UPDATE MyTable SET MyFactor = 1.23456 WHERE Field1 = 'VALUE' AND Field2
> = "VALUE2"
>
> So by using the IN clause, that nullifies any chance of optimizable tag
> use????
>
> (On a separate note, I'm not sure why the 2nd field was a fixed CHAR
> instead of a VARCHAR?  I didn't define these formats; the scripts from
> the vendor defined them.  Wonder if changing it would make a difference?)


This is helping:
http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html
http://dev.mysql.com/doc/refman/5.0/en/index-merge-optimization.html


-- 
Mike Babcock, MCP
MB Software Solutions, LLC
President, Chief Software Architect
http://mbsoftwaresolutions.com
http://fabmate.com
http://twitter.com/mbabcock16

_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/4f20dc70.2040...@mbsoftwaresolutions.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to