Skip to content

Add OR filtering for labels in epics resolver

Jan Provaznik requested to merge jp-epics-or1 into master

What does this MR do and why?

Adds OR for labels filtering for epics resolver.

DB query

https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/14861/commands/51912

 Limit  (cost=83.27..83.27 rows=1 width=1254) (actual time=126.540..126.545 rows=4 loops=1)
   Buffers: shared hit=26 read=25
   I/O Timings: read=121.592 write=0.000
   ->  Sort  (cost=83.27..83.27 rows=1 width=1254) (actual time=126.537..126.541 rows=4 loops=1)
         Sort Key: epics.id DESC
         Sort Method: quicksort  Memory: 26kB
         Buffers: shared hit=26 read=25
         I/O Timings: read=121.592 write=0.000
         ->  Nested Loop  (cost=23.01..83.26 rows=1 width=1254) (actual time=102.354..126.503 rows=4 loops=1)
               Buffers: shared hit=23 read=25
               I/O Timings: read=121.592 write=0.000
               ->  Nested Loop  (cost=22.45..80.68 rows=1 width=1254) (actual time=85.200..102.738 rows=4 loops=1)
                     Buffers: shared hit=8 read=20
                     I/O Timings: read=98.102 write=0.000
                     ->  HashAggregate  (cost=22.03..22.20 rows=17 width=4) (actual time=67.285..67.303 rows=4 loops=1)
                           Group Key: label_links.target_id
                           Buffers: shared hit=1 read=11
                           I/O Timings: read=62.844 write=0.000
                           ->  Index Scan using index_label_links_on_label_id_and_target_type on public.label_links  (cost=0.57..21.98 rows=17 width=4) (actual time=28.494..67.247 rows=4 loops=1)
                                 Index Cond: ((label_links.label_id = ANY ('{8745578,21333869}'::integer[])) AND ((label_links.target_type)::text = 'Epic'::text))
                                 Buffers: shared hit=1 read=11
                                 I/O Timings: read=62.844 write=0.000
                     ->  Index Scan using epics_pkey on public.epics  (cost=0.42..3.44 rows=1 width=1254) (actual time=8.849..8.849 rows=1 loops=4)
                           Index Cond: (epics.id = label_links.target_id)
                           Buffers: shared hit=7 read=9
                           I/O Timings: read=35.258 write=0.000
               ->  Index Scan using namespaces_pkey on public.namespaces  (cost=0.56..2.56 rows=1 width=4) (actual time=5.930..5.930 rows=1 loops=4)
                     Index Cond: (namespaces.id = epics.group_id)
                     Filter: ((namespaces.traversal_ids @> '{9970}'::integer[]) AND ((namespaces.type)::text = 'Group'::text))
                     Rows Removed by Filter: 0
                     Buffers: shared hit=15 read=5
                     I/O Timings: read=23.491 write=0.000

Related to #382969 (closed)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

  • enable Feature.enable(:or_issuable_queries)
  • sample query:
query {
  group(fullPath: "flightjs") {
    id
    epics(or: {labelName: ["Phins", "Phint"]}) {
      edges {
        node {
          id
        }
      }
    }
  }
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jan Provaznik

Merge request reports