One 400GB table, One query - Need Tuning Ideas (SQL2005)

后端 未结 24 2130
予麋鹿
予麋鹿 2021-01-30 15:03

I have a single large table which I would like to optimize. I\'m using MS-SQL 2005 server. I\'ll try to describe how it is used and if anyone has any suggestions I would appreci

24条回答
  •  感情败类
    2021-01-30 16:02

    Here is what I would do:

    • Don't create single indexes on each column. You'll be wasting space and they won't help you much (if at all)
    • Leave your primary key alone, but create a clustered index on your date column, since this is what you use in ORDER BY. That way the database engine would begin to scan the clustered key, compare columns with your supplied values and output rows that satisfy the conditions.
    • You don't need any other indexes for that. I believe even 100 values out of 100 millions for k4 would be considered poor selectivity by the optimizer (though you can try that at least).
    • if you select based on some date ranges, e.g. only data from the last month, week, year etc. you might want to look at partitioning your big table into "smaller" ones based on the date-column. Those 10-value columns would be good candidates for partition-keys too.

    BTW, you specify you entire PK in the query - assuming AND'ing in WHERE - that will select exactly 1 row.

提交回复
热议问题