Optimal query to fetch a cumulative sum in MySQL

后端 未结 2 1195
长发绾君心
长发绾君心 2021-01-04 14:18

What is \'correct\' query to fetch a cumulative sum in MySQL?

I\'ve a table where I keep information about files, one column list contains the size

2条回答
  •  鱼传尺愫
    2021-01-04 14:47

    I think that MySQL is only using one of the indexes on the table. In this case, it's choosing the index on foreignId.

    Add a covering compound index that includes both primaryId and foreignId.

提交回复
热议问题