How to tell if a query will scale well?

前端 未结 5 1013
轮回少年
轮回少年 2021-02-09 01:09

What are some of the methods/techniques experienced SQL developers use to determine if a particular SQL query will scale well as load increases, rows in associated tables increa

5条回答
  •  感情败类
    2021-02-09 01:56

    Pull up the execution plan and look for any of the following:

    • Table Scan
    • [Clustered] Index Scan
    • RID Lookup
    • Bookmark Lookup
    • Key Lookup
    • Nested Loops

    Any of those things (in descending order from most to least scalable) mean that the database/query likely won't scale to much larger tables. An ideal query will have mostly index seeks, hash or merge joins, the occasional sort, and other low-impact operations (spools and so on).

    The only way to prove that it will scale, as other answers have pointed out, is to test it on data of the desired size. The above is just a rule of thumb.

提交回复
热议问题