On Thu, Jan 26, 2012 at 9:47 AM, MB Software Solutions, LLC <[email protected]> wrote: > On 1/26/2012 9:28 AM, Stephen Russell wrote: > <snipped> >>>> 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. > > > I thought the same thing, Steve. Perhaps better to run separate updates > for the 2 and 3 values for the FIELD2 multiple scenario. The math > person inside of me says "Better to pass the data once (reminds me of > "Big O notation" learned in college days), but indexes change that plan > I suppose. -----------------
I don't live by mySQL like I do SQL Server so my experience is very limited. The base plan explanation that is a part of mySQL may not give all the data that an add on by say Quest might do with say Toad for mySQL? Doing tests is the only way you find out here. The # of updates is another factor as well as the sample size to the table containing the transactions. In TSQL I have the include clause for an index. Is that available or something like that in your mySQL version? I have better index quality with include over a compound index. -- Stephen Russell 901.246-0159 cell _______________________________________________ Post Messages to: [email protected] 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/CAJidMYKu2EioruRxSi8ne58=crAsJ=7ebws3kuuc2xjtbzv...@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.

