Skip to content

Searching Issues using the `IssuableFinder` is slow

Searching issues within a project is slow. For example https://gitlab.com/gitlab-org/gitlab-ce/issues/?scope=all&utf8=%E2%9C%93&state=opened&search=slow+finder took > 10s to load:

Screen_Shot_2018-12-11_at_10.49.38

The main offending queries seem to be:

6358.247ms 	SELECT "issues".* FROM "issues" WHERE "issues"."project_id" = 13083 AND ("issues"."state" IN ('opened')) AND ("issues"."title" ILIKE '%slow%' AND "issues"."title" ILIKE '%finder%' OR "issues"."description" ILIKE '%slow%' AND "issues"."description" ILIKE '%finder%') ORDER BY "issues"."created_at" DESC, "issues"."id" DESC LIMIT 20 OFFSET 0
6290.544ms 	SELECT COUNT(*) AS count_all, "issues"."state" AS issues_state FROM "issues" WHERE "issues"."project_id" = 13083 AND ("issues"."title" ILIKE '%slow%' AND "issues"."title" ILIKE '%finder%' OR "issues"."description" ILIKE '%slow%' AND "issues"."description" ILIKE '%finder%') GROUP BY "issues"."state"

This surfaced more since we enabled issue_suggestions (https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22866) since that executes that query more often than we used to (on issue create).