Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
lcp03o
Starting Member
1 Post |
Posted - 2008-03-18 : 07:41:44
|
| HiI have a database and when I run a query on it the query takes 10 minutes to complete. I am running the following querySELECT t103.cs_flag, t103.pr_flag, SUM (t103.amount), COUNT (t103.record_id) FROM br_data t103 WHERE t103.acct_id = 12 AND (t103.state = 3 OR t103.state = 7) GROUP BY t103.cs_flag, t103.pr_flagThe br_data table doesnt seem to be using its indexes ?? And it has around a million records. Now when I export the database and import on to another SQL server and then run the same query as above it only takes 1 or 2 seconds. On the server that we are having problems with I have tried to re-build the indexes using DBCC DBREINDEX (br_data,' ',0) but this hasnt helped. I have also tried backing up the database, delete the database then restore, this also hasnt helped. I have no idea why the query runs slow on the original box, but then quick when I transfer it to another server??Both servers are running windows 2003 with SQL 2000 SP4. There are no resorrce problems such as CPU / memory, Any ideas??Thanks |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2008-03-18 : 08:53:18
|
| Are the statistics up to date on both server? Do an update statistics on both , rerun them both , first do a --clear data from bufferDBCC DROPCLEANBUFFERS--clear stored procedure cacheDBCC FREEPROCCACHEto compare on an equal levelJack Vamvas--------------------Search IT jobs from multiple sources- http://www.ITjobfeed.com |
 |
|
|
|
|
|