Page 1 of 1

mysql fastest queries

Posted: Tue Sep 28, 2010 6:56 pm
by pedroz
[not sure if this the correct category to post]

although there are some solutions for this...
what is, in your opinion, the fastest queries for this?...

C1 | C2 | C3 | C4
------------------
AA | BB | XX | XX
A1 | B1 | 12 | 34
A2 | B2 | XX | XX

When C3 and C4 = XX, UPDATE C3 = C1 AND C4 = C2

C1 | C2 | C3 | C4
------------------
AA | BB | AA | BB
A1 | B1 | 12 | 34
A2 | B2 | A2 | B2

Re: mysql fastest queries

Posted: Tue Sep 28, 2010 7:26 pm
by John Cartwright
Fastest queries? Compared to what?

I would just do

[text]UPDATE mytable SET c3 = c1, c4 = c2 WHERE c3 = 'XX' AND c4 = 'XX'[/text]

Moved to Databases.

Re: mysql fastest queries

Posted: Sun Oct 03, 2010 9:46 am
by Darhazer
use "explain " to see how your query is executed.
You can create index on C3 and C4 (one index on both fields) to speed up the lookup. You have to test if this will give you better results in terms of performance