469,267 Members | 965 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,267 developers. It's quick & easy.

Suggestions on best performance for query...

I am working on a few queries that require comparing data from several
tables. I was curious if anyone had any suggestions on ways to get
the best performance. Here is an example:
table1 (could have several million records)
table2 (could have several million records)
table3 (less than 6,000 records)

The results of the query are expected to be 0 - 25,000 records
total.

SELECT SUM(table1.col8+table1.col9) FROM table1
WHERE table1.col1 IN
(SELECT table2.col1 FROM table2
WHERE table1.col3 >= table2.col4 AND table1.col4 =
table2.col5 AND table2.col6 = 'N')
AND table1.col2 IN
(SELECT table3.col1 FROM table3
WHERE table1.col5 = table3.col2)
GROUP BY table1.col2

I havent worked out the exact syntax but that is the basics of one of
the queries. The queries would run often so I wanted to make sure
they were as fast as they could be.

Would it be better to use some other method to do this type of a
query? I wasnt sure if a JOIN would be appropriate in this case where
I am not really merging tables together.

Nov 27 '07 #1
0 1059

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Pramod Ramachandran | last post: by
193 posts views Thread by Michael B. | last post: by
11 posts views Thread by Paul Wagstaff | last post: by
2 posts views Thread by Khaled Atta | last post: by
9 posts views Thread by Luke Vogel | last post: by
2 posts views Thread by Jonathan Wood | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.