Skip to content

Latest commit

 

History

History
2 lines (2 loc) · 797 Bytes

File metadata and controls

2 lines (2 loc) · 797 Bytes

Thanks for the comment @eternal-flame-AD I re‑ran the queries on the problematic user and a control user to validate the hypotheses. Changing the composite index from (userId, folderId, id) to use DESC on id did not fix the root‑folder case; on this dataset the planner continued to prefer a backward scan on the primary key and the query still took on the order of tens of seconds. By contrast, replacing the single‑column index on userId with a composite (userId, id) consistently made the planner choose that path and brought the worst‑case root‑folder query down from ~43s to ~40ms. The "all files for a user in reverse chronological order" path also benefits and becomes sub‑millisecond, while subfolder queries remain well served by the existing (userId, folderId, id) composite.