Solved

SQL Server 2008 start working 15 times faster after rebuild indexes-this is normal or mean there is problem?

Posted on 2014-04-05
6
761 Views
Last Modified: 2014-04-08
Dear experts

I’m a C# database developer with SQL 2008. Before a month I installed SQL Server 2008 R2 over WIndows R2 over super micro MB – X10 and now I detect the follow problem:

  One database start work VERY slowly – one complicated reports start require  25 sec, when I start manually my weekly rebuild procedure the report start to finished for 1.5 sec. The rebuild procedure is a SQL Agent task  - rebuild index, shrink DB, update statistics over all databases /system DBs included/. I check its history – it is run once time a week. Before I manually start the Maitanance plan, I restart the SQL Servers – it do not help. So I’m sure – the maitanance plan fix the problem.

 So now all is fine, but I start wonder – is it normal such behavior ? The DB is not heavy used, I’m afraid that this could mean HDD problem ? Is there somethink additional I should check ? I try in Windows Log, but find no problem…
0
Comment
Question by:dvplayltd
  • 3
  • 2
6 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39979777
you would need to compare a execution plan of before a index rebuild and after...
apart from that:
* do your indexes have their own filegroup?
* do all of your tables have clustered indexes (which should NOT be on the index filegroup, but the regular table filegroup)

anyhow, indeed some "regular" index rebuild may help, though I recommend doing it too often for the full system, but instead eventually "regularly" on a dedicated table, if needed.
0
 

Author Comment

by:dvplayltd
ID: 39979954
To angel

Thanks for your advice. In fact I’m not very aware of indexes and DB performance .. but I’ll become I guess …

My indexes do not have its own filegroup /you mean the index to be saved on a separated file, right?/

I have one clustrered index for every table with INT .It is on primary DB file

What is interesting is that I found the problem, when I get a backup of SQL Server /remote/ and restore it on my DEV computers and the report of my DEV computer is done for 1,5 sec. Then I release the problem is not because of database desing and becuase the report is over 5 mounths, so I start a Maitance plan Rebuild DB on remote server and all is going fine.

 The procedure of restoreing a Database from full backup do not include internally reindexes, right? Then why the this fix the problem with DB speed??? My DEV PC is not so fast than the server ...

I get the feeling that the problem is solved actually NOT from the rebuild index, but from page reorder of data /this is included in my Rebuild DB Maitance/. What do you think, how can I make additional check what and why is happened? I’m sure, this will happened again, now the DB is not heavy used but with sure it will be in few months
0
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 500 total points
ID: 39983767
>> rebuild index, shrink DB, update statistics over all databases /system DBs included/ <<

That sequence is stepping over itself.

When you shrink a db, you can fragment all tables a lot.  Therefore, never routinely shrink a database.  You can shrink a specific database file(s) if you're deleted a lot of data and/or there's a lot of freespace in that file.

When you update statistics, you also lose all the stats from the index rebuilds.

Instead, you need to rebuild only indexes that are fragmented, specifying SORT_IN_TEMPDB if possible.  You should update statistics only on non-rebuilt indexes.

No, I don't think a maintenance plan can do that for you automatically.  You would need some type of custom code.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:dvplayltd
ID: 39984964
To Scott

Thanks for your time.

For lucky next few mounts my DB will have 1-2 users for few hours per day, it size is now 100 MB so I have a time to test and to learn basic … and I’m surprised that with some small data wrong index could make 15 times faster operations …

 I was thinking that shrink make reorder of the pages and improve the speed, look the pic. I’m wrong? In fact you are correct, the shrink command I actually use do not turn on this option, but I can copy/paste t-SQL from here. What do you think? In fact, I have no problem with HDD space at all , I need to use shrink only if it help for performance.

For now I should use Maintenance plan, the business is not so big to pay a DB  administrator …

So my Maintenance plan will be:
1.      Daily update statistics /only this/
2.      One time in a week – Reorganize Index Task /instead of Shrink-this reorder index page for faster read, is that fine?/
3.      Once time in a month – rebuild index Task

This look fine to you? Other recommendation?


P.S: I’m sure your notes are correct, anyway what I detect at 100 % that after apply this wrong maintenance plan – one report from 25 sec. start to calculated for 1.5 sec. Too much difference over too small data .. is it possible to be die to HDD bad sectors
0
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 39986110
Yes, that looks like an excellent adjustment.

I guess it's possible it's a bad drive.  But those things don't usually get suddenly better, they just get worse and worse.
0
 

Author Closing Comment

by:dvplayltd
ID: 39986561
10x. I apply the new maitance plans + will check for physical bad sectors on HDDs
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question