
(fyi: mysql, or sql in general's order of evaluation is: first and, then or.) On 07/12/2010 03:39 PM, Marijn Vandevoorde wrote:
nope. it return records for which
(a=? and b =?) or c=?
which is not what you want.
mysql is probably optimizing this in a lazy way, checking C first and if that doesn't match, checking a and b.
strange that you're experiencing such a big performance jump there.
your original query can also be done lazy, but in the worst case requires 3 checks instead of (best case) 1.
so it shouldn't be more than something like 3 seconds i guess.
are you sure it wasn't just a matter of resources being used by something else, locks on tables etc.?
On 07/12/2010 03:34 PM, Michiel Van Bel wrote:
okay, I have a table with columns A, B, C There is a separate index on all columns If my query looks like this : "WHERE A=? AND (B=? OR C=?)" Then the runtime for 300 queries is about 70 seconds (which is way too long)
If my query looks like this: "WHERE A=? AND B=? OR C=?" Then the runtime for 300 queries is about 1 second (which is a lot more sensible).
Now, the question is of course, why is mysql so fucking slow, when I just add some brackets? And is the result of the first query equal to this: "WHERE A=? AND B=? OR A=? AND C=?" Or am i missing something?
-- Marijn Vandevoorde Tel:+32 (0)9 331 36 95 fax:+32 (0)9 3313809 VIB Department of Plant Systems Biology, Ghent University Technologiepark 927, 9052 Gent, BELGIUM marijn.vandevoorde@psb.vib-ugent.be http://www.psb.vib-ugent.be ================================================================== "Lets come all steal,we will lie and cheat and turn around all their limit signs and redirect this great old boring road into the depthsof a lions mouth Just to see if theres something we believe" --K. Matsson