MY SQL Performance Question (Otis + Everyone)

Posts   
 
    
MarcoP avatar
MarcoP
User
Posts: 270
Joined: 29-Sep-2004
# Posted on: 11-Jan-2011 22:15:46   

I'm looking for a little guidance here and hoping some one(s) can help out. I have a de-normalized table with 6 millions rows in it. I am utilizing server-side paging and the user can sort by any of the grid columns (10). Also, the user can search based on pretty much the same 10 or so fields.

Now, it is taking the query to run around a minute (Select Count(*) take 30 seconds and the actual select takes another 30). I think the bottle neck is the ordering by the column (when I remove ordering it is sub second). So I think I have three choices.

  1. Add a index for all search/order columns. Will this really make a difference with 6 million rows?
  2. Pick a column and make it a clustered index and sort by this guy when fetching and not allow the user to sort server side.
  3. No sorting. Very confusing for the user when using paging.

Thoughts/suggestions?

Thanks!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-Jan-2011 04:29:11   

MarcoP wrote:

I'm looking for a little guidance here and hoping some one(s) can help out. I have a de-normalized table with 6 millions rows in it. I am utilizing server-side paging and the user can sort by any of the grid columns (10). Also, the user can search based on pretty much the same 10 or so fields.

Now, it is taking the query to run around a minute (Select Count(*) take 30 seconds and the actual select takes another 30). I think the bottle neck is the ordering by the column (when I remove ordering it is sub second). So I think I have three choices.

MarcoP wrote:

  1. Add a index for all search/order columns. Will this really make a difference with 6 million rows?

I think it will make a difference, for sure. I don't know what would be the cost of having a lot of indexes in your table. (some useful info).

MarcoP wrote:

  1. Pick a column and make it a clustered index and sort by this guy when fetching and not allow the user to sort server side.
  2. No sorting. Very confusing for the user when using paging.

Sometimes we offer the user the possibility to sort on any column, but in the real life just some of them are really sorted. So you can stick with the indispensable.

David Elizondo | LLBLGen Support Team