简体   繁体   中英

SSMS 2012 local instance slow

I'm encountering an issue with my local instance of SSMS 2012, where it has suddenly started running extremely slowly. I have queries that would usually take 20-30 seconds now taking 6+ minutes. These aren't necessarily complex, just a simple join. I should note that working on a single database performs as normal (as far as my limited tests show)

The only changes I've made recently, is connecting to R using ODBC with the ODBC Driver 11 for SQL Server, straight from Microsoft's website.

I've tried deleting my ODBC connections, closing RStudio, closing SSMS and even restarted my laptop to sever any remaining connections - all to no avail.

Any help at this point would be appreciated, thanks.

Perhaps your statistics are out of date as that can cause a query that's run okay, to go downhill if there has been a lot of change in the database. You can update them using:

EXEC sp_updatestats;

Hopefully this will help. Also another thing to check is that your indexes aren't fragmented.

SELECT dbschemas.[name] as 'Schema', 
dbtables.[name] as 'Table', 
dbindexes.[name] as 'Index',
indexstats.avg_fragmentation_in_percent,
indexstats.page_count
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS indexstats
INNER JOIN sys.tables dbtables on dbtables.[object_id] = indexstats.[object_id]
INNER JOIN sys.schemas dbschemas on dbtables.[schema_id] = dbschemas.[schema_id]
INNER JOIN sys.indexes AS dbindexes ON dbindexes.[object_id] = indexstats.[object_id]
AND indexstats.index_id = dbindexes.index_id
WHERE indexstats.database_id = DB_ID()
ORDER BY indexstats.avg_fragmentation_in_percent desc

This will show a list of the objects in the current database. (Use a use statement to choose the database before running)

Use Northwind
GO

Anything that is more than 5% then use ALTER INDEX IndexName REBUILD

Anything that is more than 30% then use a ALTER INDEX IndexName REBUILD

This could take some time!

hope it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM