All Forums Tools
tester023 8 posts Joined 12/11
21 Mar 2012
performance of two columns

Hi,

could you please let me know whether there will be any difference in performance between the following two queries. As i don't have any internal knowledge about sql, i have this doubt.

table A: column alpha has 100 million records
table B: column beta has 45 million records 

 

Query 1

SELECT 
A.alpha 
FROM A
WHERE 
A.alpha = B.beta

Query 2

SELECT 
A.alpha 
FROM A
WHERE 
B.beta = A.alpha

 

will query 2 run faster than query 1 ?
 

Thank you.

 

ulrich 816 posts Joined 09/09
21 Mar 2012

Test your self by checking the explain

So run

explain
SELECT
A.alpha 
FROM A
WHERE
A.alpha = B.beta

and

Explain
SELECT 
A.alpha 
FROM A
WHERE 
B.beta = A.alpha

if the plan is the same - which I would expect - no differences can be expected.

If it is different you might also see some differences in the real resource consumption.

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

tester023 8 posts Joined 12/11
21 Mar 2012

i tried it.

the results were same.
Thank you!

You must sign in to leave a comment.