Skip to content
GitLab Next
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab FOSS GitLab FOSS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1
    • Merge requests 1
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLab FOSSGitLab FOSS
  • Merge requests
  • !10248

Optimize labels finder query

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged M. Hasbini requested to merge 0xbsec/gitlab-ce:labels-finder-optimize-project into master Mar 26, 2017
  • Overview 4
  • Commits 1
  • Pipelines 1
  • Changes 2

What does this MR do?

Optimize labels finder query when searching for a project with a group.

This query is being used when filtering labels in the search bar in issues/merge requests page.

original - https://explain.depesz.com/s/f5iI

SELECT "labels".*
FROM "labels"
WHERE (labels.id IN
         (SELECT "labels"."id"
          FROM "labels"
          WHERE "labels"."type" IN ('GroupLabel')
            AND "labels"."group_id" = 2
          UNION SELECT "labels"."id"
          FROM "labels"
          WHERE "labels"."type" IN ('ProjectLabel')
            AND "labels"."project_id" = 1))
ORDER BY "labels"."title" ASC

updated - https://explain.depesz.com/s/W5N

SELECT "labels".*
FROM "labels"
WHERE ("labels"."type" = 'GroupLabel'
       AND "labels"."group_id" = 2
       OR "labels"."type" = 'ProjectLabel'
       AND "labels"."project_id" = 1)
ORDER BY "labels"."title" ASC

Are there points in the code the reviewer needs to double check?

Why was this MR needed?

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

  • Changelog entry added, if necessary
  • Documentation created/updated
  • API support added
  • Tests
    • Added for this feature/bug
    • All builds are passing
  • Conform by the merge request performance guides
  • Conform by the style guides
  • Branch has no merge conflicts with master (if it does - rebase it please)
  • Squashed related commits together

What are the relevant issue numbers?

Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: labels-finder-optimize-project