Optimizing ORDER BY

前端 未结 5 1679
野趣味
野趣味 2021-01-21 08:21

I am trying to optimize this query that sorts posts by reputation field (1st) and then id field (2nd). Without 1st field query takes ~0.25

5条回答
  •  青春惊慌失措
    2021-01-21 08:55

    Perhaps an index with columns: id, reputation, created_at could help to speed up a bit, That would be the easiest solution, if you did not try that yet. The DBMS would not have to read so much data, to calculate the offset, limit - affected records.

提交回复
热议问题