Skip to content

Optimize issue search when sorting by due date and position

Stan Hu requested to merge sh-add-due-date-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 (https://gitlab.com/gitlab-org/gitlab/blob/02f34cd7c447b3a76880552500a1871c5f802231/app/finders/issuable_finder.rb#L367). 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).

This commit adds the remaining simple sort attributes (due date, relative position) the Issue class. This should help speed up the search query and avoid a database statement timeout.

Improves #34661 (closed)

This merge request builds atop !24208 (diffs).

Edited by 🤖 GitLab Bot 🤖

Merge request reports