Skip to content

Optimize issue search when sorting by weight

Stan Hu requested to merge sh-add-weight-simple-sort into master

When searching for issues within a project or group, IssuableFinder has an optimization that uses a CTE to filter the list of authorized issues before searching within the list for text. This CTE optimization fence is currently only used when the user specifies a simple sorting parameter, such as created_at, and not popularity. These attributes are generally stored directly with the model, so the CTE can easily do an ORDER BY without joining another table (e.g. award_emoji for popularity).

In EE, weight is another simple sorting parameter, and we should take advantage of the CTE for that. This commit adds weight to Issue.simple_sorts. When a user sorts by weight, this should help speed up the search query and avoid a database statement timeout.

Improves #34661 (closed)

Edited by 🤖 GitLab Bot 🤖

Merge request reports