Slow search in MS SQL 2008

30 Nov

When experiencing slow search in our database, we did the following to solve it (slower in production system compared to test):

Alternative 1:

  1. Use sql server profile to check which sql is slow (check reads,writes,duration)
    • use column filter with applicationname and loginname
    • start
    • perform the search
    • stop
    • save to xml and trc for later – with xml easier to search
  2. Compare table content between two databases
  3. Check index
    • USE database
      go
      select * from sys.indexes where name like ‘indexname%’
      go
  4. Compare indexes between two databases
  5. Check last rebuild of indexes
    • USE database;
      GO
      SELECT name AS Stats,
      STATS_DATE(object_id, stats_id) AS LastStatsUpdate
      FROM sys.stats
      WHERE object_id = OBJECT_ID(‘table’)
      and left(name,4)!=’_WA_’;
      GO
  6. Rebuild all indexes
  7. Reorganise all indexes

Alternative 2:

  1. Use sql server profile to check which sql is slow (check reads,writes,duration)
    • use column filter with applicationname and loginname
    • start
    • perform the search
    • stop
    • save trc
  2. Use database engine tuning advisor
    • file – new session
    • workload: use trc-file above and database
    • choose which database to run tuning
    • start analysis
    • remember to save recommendations for later
    • apply the recommendations when you have looked through the recommendations
  3. perform the search again
    • if it’s still slow run through 1-2 until the performance is satisfactory

http://stackoverflow.com/questions/581592/do-all-sql-server-versions-rebuild-indexes-automatically-or-have-a-default-rebui

http://labs.episerver.com/en/Blogs/Per/Archive/2008/7/Automatic-index-rebuild-script/

http://stackoverflow.com/questions/2831293/tsql-know-when-index-rebuild-reorg-or-updatestatistics-was-last-run-on-sql-ser

http://blog.sqlauthority.com/2008/10/03/sql-server-2008-find-if-index-is-being-used-in-database/

http://technet.microsoft.com/en-us/library/ms189858(v=sql.105).aspx

http://technet.microsoft.com/en-us/library/ms187874(v=sql.105).aspx

http://msdn.microsoft.com/en-us/library/ms177500(v=sql.105).aspx

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: