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

后端 未结 24 2088
予麋鹿
予麋鹿 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 15:43

    Your query plan basically shows the following:

    • The first op is clustered index seek with comparisons on k1, handId?, d1, k3-k6
    • Second is an entire index scan on the k1, handId? and k7
    • Third is of course the join to build the final result set
    • Sorting ORDER BY
    • TOP n (Filter)

    The plan suggest an index, which should improve perm by 81% - k1, k4, k5, k6, k3 + include d1 & k7. I don't know how long it would take to build such an index and see the results, but as I've commented here, it will effectively double the size of your table, simply because almost every column is present in the index. Also inserts will be slower.

    As many people have suggested, partitioning is the best strategy here, e.g. make one table for example have k3 values from 1 to 3, another from 4 to 7, and the third from 8 to 10. With SQL Server Enterprise partitioning is done using a CHECK constraint on this column, the query optimizer will determine which table out of n to scan/seek depending on the parameter value for the column.

提交回复
热议问题