I'm trying to pull out ids from a table that has 5 million plus records. I'm using an ASP page and SQL server 2000. The trouble I'm having is each such query takes around 5 seconds or more, during which time the database seems to grind to a halt, slowing the rest of the site down with it.
Do you have your tables indexed? Have you re-indexed the tabels recently? What data type are the IDs? Are you pulling out just the fields you need or are you doing a "SELECT *" and pulling out a lot of data you don't need?
Have you confirmed that it's the actual query taking so long or might it be the processing of the ASP page as well? Depending on exactly what you're doing, it might also make sense to move the query from ASP into a stored procedure.
Another thought- does your DB server have enough memory/processing power? And are you using separate servers for your web server & SQL 2000?
[edited by: LifeinAsia at 3:24 pm (utc) on Aug. 23, 2006]