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
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.