Query slowing down | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Query slowing down

A query I have (launched from Visual Studio 2005 VB.NET program)on a SQL 2005 database, runs very slowly. If I create a new database and restore it from the backup of the original it runs super-fast. (It always runs fast if launched from Server Management Studio oddly enough.) If I detach the original database and re-attach it, it runs fast too from the VB app.– for a day or two. I have tested with no other users active on the database and tried a manual BACKUP viz: BACKUP DATABASE InvioProd
TO InvioTestManualLogX
DBCC SHRINKDATABASE (InvioProd,10) — to no effect. Only detach/reattach appears to help. Getting frantic. Don’t know where to look next. David Bytheway
How about update statistics and table reindexing on a periodcal basis, as long as the database is optimized then you wouldn’t worry like this. When you restore or attach the database the cache will be clean and execution plans will be recreated afresh. Refer to the KBA :
.. to resolve the performance issues. (Please post the thread in relevant forums) Satya SKJ
Microsoft SQL Server MVP
Contributing Editor & Forums Moderator
This posting is provided �AS IS� with no rights for the sake of knowledge sharing.