Skip to content

Improve issue load time performance by avoiding ORDER BY in find_by call

Stan Hu requested to merge sh-fix-issue-perf-order-by-issue into master

The Sortable concern has a default scope that adds ORDER BY to all queries. EXPLAIN ANALYZE shows that this additional ORDER BY statement causes the SQL optimizer to use the wrong index, which leads to a load time of 2.9 s vs 0.073 ms just for the SELECT call. The minimal change here is to re-implement find_by using where and reorder to remove the ORDER BY clause in IssuesController#index.

Merge request reports