By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,021 Members | 912 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,021 IT Pros & Developers. It's quick & easy.

Suggestions on best performance for query...

P: n/a
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

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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.