On Wed, Jan 25, 2012 at 10:54 PM, MB Software Solutions, LLC
<mbsoftwaresoluti...@mbsoftwaresolutions.com> wrote:
> 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"
---------------------------------

Would it be better to to run separate updates?
 UPDATE MyTable SET MyFactor = 1.23456 WHERE Field1 = 'VALUE'
AND Field2 = "VALUE2" ,"VALUE3"

UPDATE MyTable SET MyFactor = 1.23456 WHERE Field1 = 'VALUE'
AND Field2 =  "VALUE3"

I read in your first url that the size of the param may be your biggest issue.




-- 
Stephen Russell

901.246-0159 cell

_______________________________________________
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/CAJidMYLj0c6a2jLMK9WVq5vd1BDC2jOKg4dD=-zbkrf2kb_...@mail.gmail.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