Index a sum column

后端 未结 5 1507
执念已碎
执念已碎 2021-02-07 02:07

Is creating an index for a column that is being summed is faster than no index?

5条回答
  •  遥遥无期
    2021-02-07 02:31

    I found indexing a column in the where(productid here) helps when using this query:

    SELECT productid, sum(quantity) FROM receipts WHERE productid = 1 GROUP BY productid

    One of my queries went from 45 seconds to almost instant once I added the index.

提交回复
热议问题