views:

1251

answers:

5

I have a large table (more than 10 millions records). this table is heavily used for search in the application. So, I had to create indexes on the table. However ,I experience a slow performance when a record is inserted or updated in the table. This is most likely because of the re-calculation of indexes.

Is there a way to improve this.

Thanks in advance

+2  A: 

We'd need to see your indexes, but likely yes.

Some things to keep in mind are that you don't want to just put an index on every column, and you don't generally want just one column per index.

The best thing to do is if you can log some actual searches, track what users are actually searching for, and create indexes targeted at those specific types of searches.

Joel Coehoorn
A: 

This is a classic engineering trade-off... you can make the shovel lighter or stronger, never both... (until a breakthrough in material science. )

More index mean more DML maintenance, means faster queries.

Fewer indexes mean less DML maintenance, means slower queries.

It could be possible that some of your indexes are redundant and could be combined.

Besides what Joel wrote, you also need to define the SLA for DML. Is it ok that it's slower, you noticed that it slowed down but does it really matter vs. the query improvement you've achieved... IOW, is it ok to have a light shovel that weak?

+2  A: 

There are a number of solutions you could choose

a) You could partition the table

b) Consider performing updates in batch at offpeak hours (like at night)

c) Since engineering is a balancing act of trade-offs, you would have to choose which is more important (Select or Update/insert/delete) and which operation is more important. Assuming you don't need the results in real time for an "insert", you can use Sql server service broker for those operations to perform the "less important" operation asynchronously

http://msdn.microsoft.com/en-us/library/ms166043(SQL.90).aspx

Thanks -RVZ

+7  A: 

You could try reducing the number of page splits (in your indexes) by reducing the fill factor on your indexes. By default, the fill factor is 0 (same as 100 percent). So, when you rebuild your indexes, the pages are completely filled. This works great for tables that are not modified (insert/update/delete). However, when data is modified, the indexes need to change. With a Fill Factor of 0, you are guaranteed to get page splits.

By modifying the fill factor, you should get better performance on inserts and updates because the page won't ALWAYS have to split. I recommend you rebuild your indexes with a Fill Factor = 90. This will leave 10% of the page empty, which would cause less page splits and therefore less I/O. It's possible that 90 is not the optimal value to use, so there may be some 'trial and error' involved here.

By using a different value for fill factor, your select queries may become slightly slower, but with a 90% fill factor, you probably won't notice it too much.

G Mastros
A: 

If you have a clustered index that is not on an identity numeric field, rearranging the pages can slow you down. If this is the case for you see if you can improve speed by making this a non-clustered index (faster than no index but tends to be a bit slower than the clustered index, so your selects may slow down but inserts improve)

I have found users more willing to tolerate a slightly slower insert or update to a slower select. That is a general rule, but if it becomes unacceptably slow (or worse times out) well no one can deal with that well.

HLGEM