views:

144

answers:

7

The current DB or our project has crossed over 40 GB this month and on an average it is growing monthly by around 3 GB. Now all the tables are best normalized and proper indexing has been used. But still as the size is growing it is taking more time to fire even basic queries like 'select count(1) from table'. So can u share some more points that will help in this front. Database is Sql Server 2005. Further if we implement Partitioning wouldn't it create a overhead ?

Thanks in advance.

+3  A: 

You should to take a look here: Improving SQL Server Performance

Rubens Farias
+7  A: 
  1. make sure you have suitable/appropriate indexes
  2. make sure you have a good index maintenance strategy (e.g. rebuild/defrag/keep statistics up to date to ensure indexes stay performing well)
  3. identify poorly performing queries and optimise them (may have been written/tested against small data volumes when performance issues would not have shown up)
  4. consider partitioning your data (e.g. SQL 2005 and onwards has built in support for partitioning if you have Enterprise Edition). Edit: to elaborate on SQL Server partitioning, I full recommend a read through this MSDN article on the whys and the hows. On a general note, there was also a good talk at QCon 2008 by Randy Shoup (eBay architect) on scalability, of which one of the key points on scaling a system in general is to partition. It's summarised here.
  5. is your db server hardware sufficient? could it benefit from more memory? Edit: looking at your comment with your hardware info, I think you could do with (at least) throwing more RAM in it
  6. you may benefit from some denormalisation. Difficult to be specific without knowing exact db structure, but denormalising may improve certain queries at the expense of data duplication/disk space
AdaTheDev
If he has 32-bit Standard edition of Windows Server 2003, he would be unable to add any more RAM.
Josh Stodola
Even if his OS did support more than 4-gigs of memory, SQL server would not be able to use more than 3-gigs (http://msdn.microsoft.com/en-us/library/aa366778(VS.85).aspx). I would suggest upgrading to a 64-bit machine.
BlueRaja - Danny Pflughoeft
I might be wrong, but has the OP mentioned somewhere he is running on 32-bit?
Frank Kalis
A: 

I think in some points you need partitioning. It is fundamental approach to scale the database.

David Gruzman
A: 

Also, you might want to go bach to basics and rethink about the reason the DB is growing and its structure. 3GB a month extra (ans probably increasing if you are succesful) is going to get you into trouble sooner or later ;-)

Jan Doggen
This poster has never administered a database before.
BlueRaja - Danny Pflughoeft
It is something I would check. There are not so many problems that generate that amount of information in a non-media database. It is possible that the solution is generating unnecesary complexity.
rapto
+4  A: 

A 40 GB database is by no means considered a big database these days. And a 3 GB growth per month is also nothing unusual.

However, in the areas you really have to be careful about some small things that you might get away with in smaller databases. Since you write about issuing a "SELECT COUNT(1) ..." query, you might want to think about the need for such queries. Sounds like this is a "displaying number of rows in the table" type of feature. Do you really need these kind of what you call "basic queries" or can you do without? Considering especially this query: do you need the result to be accurate or could it also be a "good estimate"? If so, you might want to throw in a WITH (NOLOCK) hint here and there, where accuracy is not mandatory. However, use NOLOCK wisely as it will return wrong data at a incredible speed. :-)

Plenty of good suggestions have been mentioned by AdaTheDev, just let add me one point:

Nothing gives you better performance than a sound and solid schema. And, who knows, what may has been considered appropriate at the time when you designed the schema, may need to be revised now after being in production for some time. This is especially true for indices.

Frank Kalis
++++1 for the nolock comments, wish I could get people to understand it's not always a good thing.
SqlACID
Re: `SELECT COUNT(1) FROM ...`: If you are really using this to get the number of rows in the table (as opposed to getting the number of rows with non-null values in column 1), consider going to the table metadata for this (either the `sysobjects` table or the INFORMATION_SCHEMA view).
TMN
+3  A: 

Your machine is quite low spec, however as you've not even mentioned what disk you're using, that is most likely the problem. You will need very fast disk to support a 40GB database with 4GB of RAM, multiple striped drives would be a bare minimum.

ck
I'd take a look at some profiling info first to make sure the disks are the bottleneck. Even if they are, he might get better improvement by optimizing his queries so they don't hammer the disks as much.That said, it's still a good point. A RAID array should be mandatory for any database server that supports performance-sensitive apps.
TMN
+1 for the comment above. There is little sense in throwing in hardware without a thoroughful analysis first.
Frank Kalis
+1  A: 

I would start by using Performance Monitor and SQL Server Profiler to find out which is the most critical performance limits on your system. After that you probably have a good idea where to start.

Here is one place to start: Troubleshooting Performance Problems in SQL Server 2005

Joakim Backman