Draft: Match an epic's own milestone in the epics milestone filter
What does this MR do and why?
On a group roadmap, filtering by milestone hides an epic that is set to that milestone unless one of its child issues is also in it (#579607). This MR makes the filter also match the epic's own milestone, with no new column or sync. @vshushlin closed that issue as Won't do: "we don't plan to invest capacity into improving current roadmap functionality soon". This change is small, asks only for review time, and goes away with the legacy epics filter.
Epic.in_milestone and Milestones::UpdateService are unchanged, so the milestone date recompute still reads child issues only, and a spec guards that. Only Epics::Findable#by_milestone calls the new scope, Epic.in_milestone_including_own. The GraphQL argument description now says the filter is computed from the epic and its issues. No feature flag: the filter only widens to epics it wrongly missed.
Product context
- The product position was that the fix waits for the roadmap to read work items. That rebuild has no date (#478011, &2649).
- The epic milestone design says the roadmap filter must "also account for Epics themselves". The blocker raised there was adding a milestone to legacy epics, which this change does not do.
- @mmacfarlane is the product manager for Planning Views and Portfolio Planning.
flowchart TD
F["Roadmap milestone filter"] --> B["Epics::Findable#by_milestone"]
B --> N["Epic.in_milestone_including_own, new"]
N --> C["child issue in the milestone<br/>(epic_issues)"]
N --> O["epic's own work item in the milestone<br/>(epics.issue_id)"]
C --> U["UNION ALL of epic ids, matched with id IN"]
O --> U
U --> R["epic returned"]
M["Milestones::UpdateService"] --> I["Epic.in_milestone, unchanged"]
I --> C2["child issue in the milestone only"]References
Screenshots or screen recordings
There are no screenshots: the change is which epics the roadmap lists, and the steps below show it.
How to set up and validate locally
- In a group with epics licensed, create a group milestone.
- Create an epic with a fixed start date and a fixed due date, and set its milestone to the group milestone. Add no child issue to the epic.
- Open the group roadmap, with a timeframe that includes the epic's dates, and filter by the milestone. On master the roadmap does not list the epic; with this MR it does.
- Add a child issue in the same milestone to the epic. The roadmap lists the epic once.
The roadmap lists only epics that have a start or due date, so step 2 sets both.
Database
The roadmap sends one epics query per page. The plans below are that query as the roadmap sends it (state all, sort START_DATE_ASC, timeframe 1 September 2026 to 31 March 2027, first 50, descendant groups included, LIMIT 51), for milestone 19.6, on the production clone in Database Lab. One shape is the top-level group gitlab-org (9970), the other the public subgroup gitlab-org/quality/engineering-productivity (16947798).
| Group | Version | Rows | Own-milestone epic ids | Warm ms | Warm buffer hits | Top-node cost |
|---|---|---|---|---|---|---|
| 9970 | master | 51 | n/a | 25.8 | 37,910 | 193.65 |
| 9970 | this MR | 51 | 199 | 41.5 | 64,895 | 394.96 |
| 16947798 | master | 0 | n/a | 1.9 | 382 | 1645.01 |
| 16947798 | this MR | 0 | 0 | 3.0 | 758 | 3297.62 |
- No plan has a sequential scan, and every warm run is under 100 ms with no disk reads.
- In
gitlab-org, 929 epics match before theLIMITagainst 892 on master, so 37 epics the filter hides today now appear. 199 epic ids came from the own-milestone arm. - The subgroup returns 0 rows on both versions, so it measures an empty result. It runs the same two arms as
gitlab-org. - The milestone and issue subqueries appear in both arms of the union, so the new query evaluates them twice. At a 16 ms warm difference, that did not justify a CTE.
- There is no cold column: a reset empties the Postgres cache but not the storage cache under the clone, so a first run depends on run order as much as on the query.
Finder SQL, master, group 9970, milestone 19.6
SELECT "epics".*
FROM "epics"
WHERE "epics"."group_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{9970}')))
AND ("epics"."start_date" IS NOT NULL
OR "epics"."end_date" IS NOT NULL)
AND ("epics"."start_date" IS NULL
OR "epics"."start_date" <= '2027-03-31')
AND ("epics"."end_date" IS NULL
OR "epics"."end_date" >= '2026-09-01')
AND (EXISTS
(SELECT 1
FROM "epic_issues"
INNER JOIN "issues" ON "issues"."id" = "epic_issues"."issue_id"
WHERE "issues"."milestone_id" IN
(SELECT "milestones"."id"
FROM (
(SELECT "milestones".*
FROM "milestones"
WHERE "milestones"."project_id" IN
(SELECT "projects"."id"
FROM "projects"
LEFT JOIN project_features ON projects.id = project_features.project_id
WHERE "projects"."namespace_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{9970}')))
AND ("project_features"."issues_access_level" IS NULL
OR "project_features"."issues_access_level" IN (20,
30)
OR ("project_features"."issues_access_level" = 10
AND EXISTS
(SELECT 1
FROM "project_authorizations"
WHERE "project_authorizations"."user_id" = 1
AND (project_authorizations.project_id = project_features.project_id)
AND (project_authorizations.access_level >= 10))))))
UNION ALL
(SELECT "milestones".*
FROM "milestones"
WHERE "milestones"."group_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{9970}'))))) milestones
WHERE "milestones"."title" = '19.6')
AND "epic_issues"."epic_id" = "epics"."id"))
ORDER BY "epics"."start_date" ASC NULLS LAST,
"epics"."id" DESC
LIMIT 51Warm plan, master, group 9970, milestone 19.6
Limit (cost=193.64..193.65 rows=1 width=1339) (actual time=25.540..25.557 rows=51 loops=1)
Buffers: shared hit=37910
I/O Timings: read=0.000 write=0.000
-> Sort (cost=193.64..193.65 rows=1 width=1339) (actual time=25.539..25.551 rows=51 loops=1)
Sort Key: epics.start_date, epics.id DESC
Sort Method: top-N heapsort Memory: 116kB
Buffers: shared hit=37910
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=181.03..193.63 rows=1 width=1339) (actual time=19.018..24.790 rows=892 loops=1)
Buffers: shared hit=37904
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=180.46..187.44 rows=2 width=1339) (actual time=19.002..22.977 rows=899 loops=1)
Buffers: shared hit=33409
I/O Timings: read=0.000 write=0.000
-> HashAggregate (cost=180.04..180.11 rows=7 width=4) (actual time=18.983..19.141 rows=1014 loops=1)
Group Key: epic_issues.epic_id
Batches: 1 Memory Usage: 153kB
Buffers: shared hit=29353
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=80.56..180.02 rows=7 width=4) (actual time=0.423..18.335 rows=3024 loops=1)
Buffers: shared hit=29353
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=80.13..95.73 rows=187 width=4) (actual time=0.412..4.426 rows=6478 loops=1)
Buffers: shared hit=6895
I/O Timings: read=0.000 write=0.000
-> Unique (cost=79.56..79.57 rows=2 width=4) (actual time=0.387..0.396 rows=1 loops=1)
Buffers: shared hit=279
I/O Timings: read=0.000 write=0.000
-> Sort (cost=79.56..79.57 rows=2 width=4) (actual time=0.386..0.394 rows=1 loops=1)
Sort Key: "*SELECT* 1".id
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=279
I/O Timings: read=0.000 write=0.000
-> Append (cost=2.13..79.55 rows=2 width=4) (actual time=0.369..0.385 rows=1 loops=1)
Buffers: shared hit=279
I/O Timings: read=0.000 write=0.000
-> Subquery Scan on "*SELECT* 1" (cost=2.13..52.06 rows=1 width=4) (actual time=0.327..0.331 rows=0 loops=1)
Buffers: shared hit=232
I/O Timings: read=0.000 write=0.000
-> Nested Loop Semi Join (cost=2.13..52.05 rows=1 width=1176) (actual time=0.326..0.329 rows=0 loops=1)
Buffers: shared hit=232
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_milestones_on_title on public.milestones milestones_1 (cost=0.43..9.52 rows=5 width=8) (actual time=0.015..0.037 rows=19 loops=1)
Index Cond: ((milestones_1.title)::text = '19.6'::text)
Buffers: shared hit=22
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1.70..8.50 rows=1 width=4) (actual time=0.015..0.015 rows=0 loops=19)
Buffers: shared hit=210
I/O Timings: read=0.000 write=0.000
-> Nested Loop Left Join (cost=1.13..7.84 rows=1 width=8) (actual time=0.011..0.011 rows=1 loops=19)
Filter: ((project_features.issues_access_level IS NULL) OR (project_features.issues_access_level = ANY ('{20,30}'::integer[])) OR ((project_features.issues_access_level = 10) AND EXISTS(SubPlan 1)))
Buffers: shared hit=145
I/O Timings: read=0.000 write=0.000
-> Index Scan using idx_projects_on_repository_storage_last_repository_updated_at on public.projects (cost=0.56..3.58 rows=1 width=8) (actual time=0.005..0.005 rows=1 loops=19)
Index Cond: (projects.id = milestones_1.project_id)
Buffers: shared hit=71
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_project_features_on_project_id on public.project_features (cost=0.56..0.64 rows=1 width=8) (actual time=0.007..0.007 rows=1 loops=14)
Index Cond: (project_features.project_id = projects.id)
Buffers: shared hit=70
I/O Timings: read=0.000 write=0.000
SubPlan 1
-> Index Only Scan using index_project_authorizations_on_project_user_access_level on public.project_authorizations (cost=0.58..3.60 rows=1 width=0) (actual time=0.011..0.011 rows=0 loops=1)
Index Cond: ((project_authorizations.project_id = project_features.project_id) AND (project_authorizations.user_id = 1) AND (project_authorizations.access_level >= 10))
Heap Fetches: 0
Buffers: shared hit=4
I/O Timings: read=0.000 write=0.000
-> Index Scan using namespaces_pkey on public.namespaces namespaces_1 (cost=0.57..0.66 rows=1 width=4) (actual time=0.005..0.005 rows=0 loops=13)
Index Cond: (namespaces_1.id = projects.namespace_id)
Filter: ((namespaces_1.traversal_ids @> '{9970}'::integer[]) AND ((namespaces_1.type)::text = 'Group'::text))
Rows Removed by Filter: 1
Buffers: shared hit=65
I/O Timings: read=0.000 write=0.000
-> Subquery Scan on "*SELECT* 2" (cost=1.00..27.48 rows=1 width=4) (actual time=0.042..0.052 rows=1 loops=1)
Buffers: shared hit=47
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1.00..27.47 rows=1 width=1176) (actual time=0.041..0.051 rows=1 loops=1)
Buffers: shared hit=47
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_milestones_on_title on public.milestones milestones_2 (cost=0.43..9.52 rows=5 width=8) (actual time=0.008..0.015 rows=19 loops=1)
Index Cond: ((milestones_2.title)::text = '19.6'::text)
Buffers: shared hit=22
I/O Timings: read=0.000 write=0.000
-> Index Scan using namespaces_pkey on public.namespaces namespaces_2 (cost=0.57..3.59 rows=1 width=4) (actual time=0.002..0.002 rows=0 loops=19)
Index Cond: (namespaces_2.id = milestones_2.group_id)
Filter: ((namespaces_2.traversal_ids @> '{9970}'::integer[]) AND ((namespaces_2.type)::text = 'Group'::text))
Buffers: shared hit=25
I/O Timings: read=0.000 write=0.000
-> Index Only Scan using index_issues_on_milestone_id_and_id on public.issues (cost=0.57..7.14 rows=94 width=8) (actual time=0.024..3.402 rows=6478 loops=1)
Index Cond: (issues.milestone_id = "*SELECT* 1".id)
Heap Fetches: 1059
Buffers: shared hit=6616
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_epic_issues_on_issue_id on public.epic_issues (cost=0.43..0.45 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=6478)
Index Cond: (epic_issues.issue_id = issues.id)
Buffers: shared hit=22458
I/O Timings: read=0.000 write=0.000
-> Index Scan using epics_pkey on public.epics (cost=0.42..1.05 rows=1 width=1339) (actual time=0.003..0.003 rows=1 loops=1014)
Index Cond: (epics.id = epic_issues.epic_id)
Filter: (((epics.start_date IS NOT NULL) OR (epics.end_date IS NOT NULL)) AND ((epics.start_date IS NULL) OR (epics.start_date <= '2027-03-31'::date)) AND ((epics.end_date IS NULL) OR (epics.end_date >= '2026-09-01'::date)))
Buffers: shared hit=4056
I/O Timings: read=0.000 write=0.000
-> Index Scan using namespaces_pkey on public.namespaces (cost=0.57..3.10 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=899)
Index Cond: (namespaces.id = epics.group_id)
Filter: ((namespaces.traversal_ids @> '{9970}'::integer[]) AND ((namespaces.type)::text = 'Group'::text))
Buffers: shared hit=4495
I/O Timings: read=0.000 write=0.000
Settings: seq_page_cost = '4', effective_cache_size = '472585MB', work_mem = '230MB', jit = 'off', random_page_cost = '1.5'
Query ID: 346869006058465035Database Lab link: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/93493/commands/199477
Finder SQL, this MR, group 9970, milestone 19.6
SELECT "epics".*
FROM "epics"
WHERE "epics"."group_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{9970}')))
AND ("epics"."start_date" IS NOT NULL
OR "epics"."end_date" IS NOT NULL)
AND ("epics"."start_date" IS NULL
OR "epics"."start_date" <= '2027-03-31')
AND ("epics"."end_date" IS NULL
OR "epics"."end_date" >= '2026-09-01')
AND "epics"."id" IN (
(SELECT "epic_issues"."epic_id"
FROM "epic_issues"
INNER JOIN "issues" ON "issues"."id" = "epic_issues"."issue_id"
WHERE "issues"."milestone_id" IN
(SELECT "milestones"."id"
FROM (
(SELECT "milestones".*
FROM "milestones"
WHERE "milestones"."project_id" IN
(SELECT "projects"."id"
FROM "projects"
LEFT JOIN project_features ON projects.id = project_features.project_id
WHERE "projects"."namespace_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{9970}')))
AND ("project_features"."issues_access_level" IS NULL
OR "project_features"."issues_access_level" IN (20,
30)
OR ("project_features"."issues_access_level" = 10
AND EXISTS
(SELECT 1
FROM "project_authorizations"
WHERE "project_authorizations"."user_id" = 1
AND (project_authorizations.project_id = project_features.project_id)
AND (project_authorizations.access_level >= 10))))))
UNION ALL
(SELECT "milestones".*
FROM "milestones"
WHERE "milestones"."group_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{9970}'))))) milestones
WHERE "milestones"."title" = '19.6'))
UNION ALL
(SELECT "epics"."id"
FROM "epics"
WHERE "epics"."issue_id" IN
(SELECT "issues"."id"
FROM "issues"
WHERE "issues"."milestone_id" IN
(SELECT "milestones"."id"
FROM (
(SELECT "milestones".*
FROM "milestones"
WHERE "milestones"."project_id" IN
(SELECT "projects"."id"
FROM "projects"
LEFT JOIN project_features ON projects.id = project_features.project_id
WHERE "projects"."namespace_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{9970}')))
AND ("project_features"."issues_access_level" IS NULL
OR "project_features"."issues_access_level" IN (20,
30)
OR ("project_features"."issues_access_level" = 10
AND EXISTS
(SELECT 1
FROM "project_authorizations"
WHERE "project_authorizations"."user_id" = 1
AND (project_authorizations.project_id = project_features.project_id)
AND (project_authorizations.access_level >= 10))))))
UNION ALL
(SELECT "milestones".*
FROM "milestones"
WHERE "milestones"."group_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{9970}'))))) milestones
WHERE "milestones"."title" = '19.6'))))
ORDER BY "epics"."start_date" ASC NULLS LAST,
"epics"."id" DESC
LIMIT 51Warm plan, this MR, group 9970, milestone 19.6
Limit (cost=394.96..394.96 rows=1 width=1339) (actual time=41.122..41.148 rows=51 loops=1)
Buffers: shared hit=64895
I/O Timings: read=0.000 write=0.000
-> Sort (cost=394.96..394.96 rows=1 width=1339) (actual time=41.120..41.142 rows=51 loops=1)
Sort Key: epics.start_date, epics.id DESC
Sort Method: top-N heapsort Memory: 116kB
Buffers: shared hit=64895
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=362.08..394.95 rows=1 width=1339) (actual time=34.775..40.342 rows=929 loops=1)
Buffers: shared hit=64889
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=361.52..388.75 rows=2 width=1339) (actual time=34.764..38.552 rows=936 loops=1)
Buffers: shared hit=60209
I/O Timings: read=0.000 write=0.000
-> HashAggregate (cost=361.09..361.17 rows=8 width=4) (actual time=34.751..34.926 rows=1082 loops=1)
Group Key: epic_issues.epic_id
Batches: 1 Memory Usage: 153kB
Buffers: shared hit=55881
I/O Timings: read=0.000 write=0.000
-> Append (cost=80.56..361.07 rows=8 width=4) (actual time=0.444..34.023 rows=3223 loops=1)
Buffers: shared hit=55881
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=80.56..180.02 rows=7 width=4) (actual time=0.443..18.799 rows=3024 loops=1)
Buffers: shared hit=29353
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=80.13..95.73 rows=187 width=4) (actual time=0.436..4.586 rows=6478 loops=1)
Buffers: shared hit=6895
I/O Timings: read=0.000 write=0.000
-> Unique (cost=79.56..79.57 rows=2 width=4) (actual time=0.416..0.425 rows=1 loops=1)
Buffers: shared hit=279
I/O Timings: read=0.000 write=0.000
-> Sort (cost=79.56..79.57 rows=2 width=4) (actual time=0.415..0.423 rows=1 loops=1)
Sort Key: "*SELECT* 1".id
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=279
I/O Timings: read=0.000 write=0.000
-> Append (cost=2.13..79.55 rows=2 width=4) (actual time=0.398..0.415 rows=1 loops=1)
Buffers: shared hit=279
I/O Timings: read=0.000 write=0.000
-> Subquery Scan on "*SELECT* 1" (cost=2.13..52.06 rows=1 width=4) (actual time=0.345..0.350 rows=0 loops=1)
Buffers: shared hit=232
I/O Timings: read=0.000 write=0.000
-> Nested Loop Semi Join (cost=2.13..52.05 rows=1 width=1176) (actual time=0.344..0.349 rows=0 loops=1)
Buffers: shared hit=232
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_milestones_on_title on public.milestones milestones_1 (cost=0.43..9.52 rows=5 width=8) (actual time=0.015..0.040 rows=19 loops=1)
Index Cond: ((milestones_1.title)::text = '19.6'::text)
Buffers: shared hit=22
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1.70..8.50 rows=1 width=4) (actual time=0.016..0.016 rows=0 loops=19)
Buffers: shared hit=210
I/O Timings: read=0.000 write=0.000
-> Nested Loop Left Join (cost=1.13..7.84 rows=1 width=8) (actual time=0.011..0.011 rows=1 loops=19)
Filter: ((project_features.issues_access_level IS NULL) OR (project_features.issues_access_level = ANY ('{20,30}'::integer[])) OR ((project_features.issues_access_level = 10) AND EXISTS(SubPlan 1)))
Buffers: shared hit=145
I/O Timings: read=0.000 write=0.000
-> Index Scan using idx_projects_on_repository_storage_last_repository_updated_at on public.projects (cost=0.56..3.58 rows=1 width=8) (actual time=0.005..0.005 rows=1 loops=19)
Index Cond: (projects.id = milestones_1.project_id)
Buffers: shared hit=71
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_project_features_on_project_id on public.project_features (cost=0.56..0.64 rows=1 width=8) (actual time=0.007..0.007 rows=1 loops=14)
Index Cond: (project_features.project_id = projects.id)
Buffers: shared hit=70
I/O Timings: read=0.000 write=0.000
SubPlan 1
-> Index Only Scan using index_project_authorizations_on_project_user_access_level on public.project_authorizations (cost=0.58..3.60 rows=1 width=0) (actual time=0.013..0.013 rows=0 loops=1)
Index Cond: ((project_authorizations.project_id = project_features.project_id) AND (project_authorizations.user_id = 1) AND (project_authorizations.access_level >= 10))
Heap Fetches: 0
Buffers: shared hit=4
I/O Timings: read=0.000 write=0.000
-> Index Scan using namespaces_pkey on public.namespaces namespaces_1 (cost=0.57..0.66 rows=1 width=4) (actual time=0.006..0.006 rows=0 loops=13)
Index Cond: (namespaces_1.id = projects.namespace_id)
Filter: ((namespaces_1.traversal_ids @> '{9970}'::integer[]) AND ((namespaces_1.type)::text = 'Group'::text))
Rows Removed by Filter: 1
Buffers: shared hit=65
I/O Timings: read=0.000 write=0.000
-> Subquery Scan on "*SELECT* 2" (cost=1.00..27.48 rows=1 width=4) (actual time=0.052..0.063 rows=1 loops=1)
Buffers: shared hit=47
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1.00..27.47 rows=1 width=1176) (actual time=0.052..0.062 rows=1 loops=1)
Buffers: shared hit=47
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_milestones_on_title on public.milestones milestones_2 (cost=0.43..9.52 rows=5 width=8) (actual time=0.008..0.015 rows=19 loops=1)
Index Cond: ((milestones_2.title)::text = '19.6'::text)
Buffers: shared hit=22
I/O Timings: read=0.000 write=0.000
-> Index Scan using namespaces_pkey on public.namespaces namespaces_2 (cost=0.57..3.59 rows=1 width=4) (actual time=0.002..0.002 rows=0 loops=19)
Index Cond: (namespaces_2.id = milestones_2.group_id)
Filter: ((namespaces_2.traversal_ids @> '{9970}'::integer[]) AND ((namespaces_2.type)::text = 'Group'::text))
Buffers: shared hit=25
I/O Timings: read=0.000 write=0.000
-> Index Only Scan using index_issues_on_milestone_id_and_id on public.issues (cost=0.57..7.14 rows=94 width=8) (actual time=0.019..3.564 rows=6478 loops=1)
Index Cond: (issues.milestone_id = "*SELECT* 1".id)
Heap Fetches: 1059
Buffers: shared hit=6616
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_epic_issues_on_issue_id on public.epic_issues (cost=0.43..0.45 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=6478)
Index Cond: (epic_issues.issue_id = issues.id)
Buffers: shared hit=22458
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=96.62..181.01 rows=1 width=4) (actual time=4.861..14.949 rows=199 loops=1)
Buffers: shared hit=26528
I/O Timings: read=0.000 write=0.000
-> HashAggregate (cost=96.20..98.07 rows=187 width=4) (actual time=4.611..5.283 rows=6478 loops=1)
Group Key: issues_1.id
Batches: 1 Memory Usage: 481kB
Buffers: shared hit=6895
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=80.13..95.73 rows=187 width=4) (actual time=0.306..3.234 rows=6478 loops=1)
Buffers: shared hit=6895
I/O Timings: read=0.000 write=0.000
-> Unique (cost=79.56..79.57 rows=2 width=4) (actual time=0.286..0.294 rows=1 loops=1)
Buffers: shared hit=279
I/O Timings: read=0.000 write=0.000
-> Sort (cost=79.56..79.57 rows=2 width=4) (actual time=0.286..0.292 rows=1 loops=1)
Sort Key: "*SELECT* 1_1".id
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=279
I/O Timings: read=0.000 write=0.000
-> Append (cost=2.13..79.55 rows=2 width=4) (actual time=0.269..0.283 rows=1 loops=1)
Buffers: shared hit=279
I/O Timings: read=0.000 write=0.000
-> Subquery Scan on "*SELECT* 1_1" (cost=2.13..52.06 rows=1 width=4) (actual time=0.232..0.235 rows=0 loops=1)
Buffers: shared hit=232
I/O Timings: read=0.000 write=0.000
-> Nested Loop Semi Join (cost=2.13..52.05 rows=1 width=1176) (actual time=0.231..0.234 rows=0 loops=1)
Buffers: shared hit=232
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_milestones_on_title on public.milestones milestones_4 (cost=0.43..9.52 rows=5 width=8) (actual time=0.019..0.031 rows=19 loops=1)
Index Cond: ((milestones_4.title)::text = '19.6'::text)
Buffers: shared hit=22
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1.70..8.50 rows=1 width=4) (actual time=0.010..0.010 rows=0 loops=19)
Buffers: shared hit=210
I/O Timings: read=0.000 write=0.000
-> Nested Loop Left Join (cost=1.13..7.84 rows=1 width=8) (actual time=0.007..0.007 rows=1 loops=19)
Filter: ((project_features_1.issues_access_level IS NULL) OR (project_features_1.issues_access_level = ANY ('{20,30}'::integer[])) OR ((project_features_1.issues_access_level = 10) AND EXISTS(SubPlan 3)))
Buffers: shared hit=145
I/O Timings: read=0.000 write=0.000
-> Index Scan using idx_projects_on_repository_storage_last_repository_updated_at on public.projects projects_1 (cost=0.56..3.58 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=19)
Index Cond: (projects_1.id = milestones_4.project_id)
Buffers: shared hit=71
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_project_features_on_project_id on public.project_features project_features_1 (cost=0.56..0.64 rows=1 width=8) (actual time=0.004..0.004 rows=1 loops=14)
Index Cond: (project_features_1.project_id = projects_1.id)
Buffers: shared hit=70
I/O Timings: read=0.000 write=0.000
SubPlan 3
-> Index Only Scan using index_project_authorizations_on_project_user_access_level on public.project_authorizations project_authorizations_1 (cost=0.58..3.60 rows=1 width=0) (actual time=0.011..0.011 rows=0 loops=1)
Index Cond: ((project_authorizations_1.project_id = project_features_1.project_id) AND (project_authorizations_1.user_id = 1) AND (project_authorizations_1.access_level >= 10))
Heap Fetches: 0
Buffers: shared hit=4
I/O Timings: read=0.000 write=0.000
-> Index Scan using namespaces_pkey on public.namespaces namespaces_3 (cost=0.57..0.66 rows=1 width=4) (actual time=0.004..0.004 rows=0 loops=13)
Index Cond: (namespaces_3.id = projects_1.namespace_id)
Filter: ((namespaces_3.traversal_ids @> '{9970}'::integer[]) AND ((namespaces_3.type)::text = 'Group'::text))
Rows Removed by Filter: 1
Buffers: shared hit=65
I/O Timings: read=0.000 write=0.000
-> Subquery Scan on "*SELECT* 2_1" (cost=1.00..27.48 rows=1 width=4) (actual time=0.037..0.047 rows=1 loops=1)
Buffers: shared hit=47
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1.00..27.47 rows=1 width=1176) (actual time=0.036..0.046 rows=1 loops=1)
Buffers: shared hit=47
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_milestones_on_title on public.milestones milestones_5 (cost=0.43..9.52 rows=5 width=8) (actual time=0.009..0.015 rows=19 loops=1)
Index Cond: ((milestones_5.title)::text = '19.6'::text)
Buffers: shared hit=22
I/O Timings: read=0.000 write=0.000
-> Index Scan using namespaces_pkey on public.namespaces namespaces_4 (cost=0.57..3.59 rows=1 width=4) (actual time=0.001..0.001 rows=0 loops=19)
Index Cond: (namespaces_4.id = milestones_5.group_id)
Filter: ((namespaces_4.traversal_ids @> '{9970}'::integer[]) AND ((namespaces_4.type)::text = 'Group'::text))
Buffers: shared hit=25
I/O Timings: read=0.000 write=0.000
-> Index Only Scan using index_issues_on_milestone_id_and_id on public.issues issues_1 (cost=0.57..7.14 rows=94 width=8) (actual time=0.018..2.378 rows=6478 loops=1)
Index Cond: (issues_1.milestone_id = "*SELECT* 1_1".id)
Heap Fetches: 1059
Buffers: shared hit=6616
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_unique_epics_on_issue_id on public.epics epics_1 (cost=0.42..0.44 rows=1 width=8) (actual time=0.001..0.001 rows=0 loops=6478)
Index Cond: (epics_1.issue_id = issues_1.id)
Buffers: shared hit=19633
I/O Timings: read=0.000 write=0.000
-> Index Scan using epics_pkey on public.epics (cost=0.42..3.45 rows=1 width=1339) (actual time=0.003..0.003 rows=1 loops=1082)
Index Cond: (epics.id = epic_issues.epic_id)
Filter: (((epics.start_date IS NOT NULL) OR (epics.end_date IS NOT NULL)) AND ((epics.start_date IS NULL) OR (epics.start_date <= '2027-03-31'::date)) AND ((epics.end_date IS NULL) OR (epics.end_date >= '2026-09-01'::date)))
Buffers: shared hit=4328
I/O Timings: read=0.000 write=0.000
-> Index Scan using namespaces_pkey on public.namespaces (cost=0.57..3.10 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=936)
Index Cond: (namespaces.id = epics.group_id)
Filter: ((namespaces.traversal_ids @> '{9970}'::integer[]) AND ((namespaces.type)::text = 'Group'::text))
Buffers: shared hit=4680
I/O Timings: read=0.000 write=0.000
Settings: jit = 'off', random_page_cost = '1.5', seq_page_cost = '4', effective_cache_size = '472585MB', work_mem = '230MB'
Query ID: -1225377395793624447Database Lab link: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/93493/commands/199478
Finder SQL, master, subgroup 16947798, milestone 19.6
SELECT "epics".*
FROM "epics"
WHERE "epics"."group_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{16947798}')))
AND ("epics"."start_date" IS NOT NULL
OR "epics"."end_date" IS NOT NULL)
AND ("epics"."start_date" IS NULL
OR "epics"."start_date" <= '2027-03-31')
AND ("epics"."end_date" IS NULL
OR "epics"."end_date" >= '2026-09-01')
AND (EXISTS
(SELECT 1
FROM "epic_issues"
INNER JOIN "issues" ON "issues"."id" = "epic_issues"."issue_id"
WHERE "issues"."milestone_id" IN
(SELECT "milestones"."id"
FROM (
(SELECT "milestones".*
FROM "milestones"
WHERE "milestones"."project_id" IN
(SELECT "projects"."id"
FROM "projects"
LEFT JOIN project_features ON projects.id = project_features.project_id
WHERE "projects"."namespace_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{16947798}')))
AND ("project_features"."issues_access_level" IS NULL
OR "project_features"."issues_access_level" IN (20,
30)
OR ("project_features"."issues_access_level" = 10
AND EXISTS
(SELECT 1
FROM "project_authorizations"
WHERE "project_authorizations"."user_id" = 1
AND (project_authorizations.project_id = project_features.project_id)
AND (project_authorizations.access_level >= 10))))))
UNION ALL
(SELECT "milestones".*
FROM "milestones"
WHERE "milestones"."group_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND ("namespaces"."id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{16947798}')))
OR "namespaces"."id" = 1214)))) milestones
WHERE "milestones"."title" = '19.6')
AND "epic_issues"."epic_id" = "epics"."id"))
ORDER BY "epics"."start_date" ASC NULLS LAST,
"epics"."id" DESC
LIMIT 51Warm plan, master, subgroup 16947798, milestone 19.6
Limit (cost=1645.00..1645.01 rows=1 width=1339) (actual time=1.571..1.576 rows=0 loops=1)
Buffers: shared hit=382
I/O Timings: read=0.000 write=0.000
-> Sort (cost=1645.00..1645.01 rows=1 width=1339) (actual time=1.570..1.574 rows=0 loops=1)
Sort Key: epics.start_date, epics.id DESC
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=382
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1632.33..1644.99 rows=1 width=1339) (actual time=1.543..1.548 rows=0 loops=1)
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1631.76..1638.74 rows=2 width=1339) (actual time=1.543..1.547 rows=0 loops=1)
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> HashAggregate (cost=1631.34..1631.41 rows=7 width=4) (actual time=1.542..1.546 rows=0 loops=1)
Group Key: epic_issues.epic_id
Batches: 1 Memory Usage: 24kB
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1531.86..1631.32 rows=7 width=4) (actual time=1.540..1.544 rows=0 loops=1)
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1531.43..1547.03 rows=187 width=4) (actual time=1.539..1.543 rows=0 loops=1)
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Unique (cost=1530.86..1530.87 rows=2 width=4) (actual time=1.539..1.542 rows=0 loops=1)
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Sort (cost=1530.86..1530.86 rows=2 width=4) (actual time=1.539..1.542 rows=0 loops=1)
Sort Key: "*SELECT* 1".id
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Append (cost=2.13..1530.85 rows=2 width=4) (actual time=1.530..1.533 rows=0 loops=1)
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Subquery Scan on "*SELECT* 1" (cost=2.13..52.07 rows=1 width=4) (actual time=0.378..0.379 rows=0 loops=1)
Buffers: shared hit=232
I/O Timings: read=0.000 write=0.000
-> Nested Loop Semi Join (cost=2.13..52.06 rows=1 width=1176) (actual time=0.377..0.379 rows=0 loops=1)
Buffers: shared hit=232
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_milestones_on_title on public.milestones milestones_1 (cost=0.43..9.52 rows=5 width=8) (actual time=0.021..0.046 rows=19 loops=1)
Index Cond: ((milestones_1.title)::text = '19.6'::text)
Buffers: shared hit=22
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1.70..8.50 rows=1 width=4) (actual time=0.017..0.017 rows=0 loops=19)
Buffers: shared hit=210
I/O Timings: read=0.000 write=0.000
-> Nested Loop Left Join (cost=1.13..7.84 rows=1 width=8) (actual time=0.013..0.013 rows=1 loops=19)
Filter: ((project_features.issues_access_level IS NULL) OR (project_features.issues_access_level = ANY ('{20,30}'::integer[])) OR ((project_features.issues_access_level = 10) AND EXISTS(SubPlan 1)))
Buffers: shared hit=145
I/O Timings: read=0.000 write=0.000
-> Index Scan using idx_projects_on_repository_storage_last_repository_updated_at on public.projects (cost=0.56..3.58 rows=1 width=8) (actual time=0.005..0.006 rows=1 loops=19)
Index Cond: (projects.id = milestones_1.project_id)
Buffers: shared hit=71
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_project_features_on_project_id on public.project_features (cost=0.56..0.64 rows=1 width=8) (actual time=0.008..0.008 rows=1 loops=14)
Index Cond: (project_features.project_id = projects.id)
Buffers: shared hit=70
I/O Timings: read=0.000 write=0.000
SubPlan 1
-> Index Only Scan using index_project_authorizations_on_project_user_access_level on public.project_authorizations (cost=0.58..3.60 rows=1 width=0) (actual time=0.014..0.014 rows=0 loops=1)
Index Cond: ((project_authorizations.project_id = project_features.project_id) AND (project_authorizations.user_id = 1) AND (project_authorizations.access_level >= 10))
Heap Fetches: 0
Buffers: shared hit=4
I/O Timings: read=0.000 write=0.000
-> Index Scan using namespaces_pkey on public.namespaces namespaces_1 (cost=0.57..0.66 rows=1 width=4) (actual time=0.006..0.006 rows=0 loops=13)
Index Cond: (namespaces_1.id = projects.namespace_id)
Filter: ((namespaces_1.traversal_ids @> '{16947798}'::integer[]) AND ((namespaces_1.type)::text = 'Group'::text))
Rows Removed by Filter: 1
Buffers: shared hit=65
I/O Timings: read=0.000 write=0.000
-> Subquery Scan on "*SELECT* 2" (cost=292.45..1478.77 rows=1 width=4) (actual time=1.151..1.152 rows=0 loops=1)
Buffers: shared hit=144
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=292.45..1478.76 rows=1 width=1176) (actual time=1.151..1.151 rows=0 loops=1)
Buffers: shared hit=144
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_milestones_on_title on public.milestones milestones_2 (cost=0.43..9.52 rows=5 width=8) (actual time=0.010..0.022 rows=19 loops=1)
Index Cond: ((milestones_2.title)::text = '19.6'::text)
Buffers: shared hit=22
I/O Timings: read=0.000 write=0.000
-> Index Only Scan using index_namespaces_on_type_and_id on public.namespaces namespaces_2 (cost=292.02..293.85 rows=1 width=4) (actual time=0.059..0.059 rows=0 loops=19)
Index Cond: ((namespaces_2.type = 'Group'::text) AND (namespaces_2.id = milestones_2.group_id))
Heap Fetches: 0
Filter: ((ANY (namespaces_2.id = (hashed SubPlan 3).col1)) OR (namespaces_2.id = 1214))
Buffers: shared hit=122
I/O Timings: read=0.000 write=0.000
SubPlan 3
-> Bitmap Heap Scan on public.namespaces namespaces_3 (cost=173.44..291.26 rows=77 width=4) (actual time=1.060..1.061 rows=1 loops=1)
Recheck Cond: ((namespaces_3.traversal_ids @> '{16947798}'::integer[]) AND ((namespaces_3.type)::text = 'Group'::text))
Heap Blocks: exact=1
Buffers: shared hit=98
I/O Timings: read=0.000 write=0.000
-> Bitmap Index Scan on index_namespaces_on_traversal_ids_for_groups (cost=0.00..173.42 rows=77 width=0) (actual time=1.054..1.055 rows=1 loops=1)
Index Cond: (namespaces_3.traversal_ids @> '{16947798}'::integer[])
Buffers: shared hit=97
I/O Timings: read=0.000 write=0.000
-> Index Only Scan using index_issues_on_milestone_id_and_id on public.issues (cost=0.57..7.14 rows=94 width=8) (never executed)
Index Cond: (issues.milestone_id = "*SELECT* 1".id)
Heap Fetches: 0
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_epic_issues_on_issue_id on public.epic_issues (cost=0.43..0.45 rows=1 width=8) (never executed)
Index Cond: (epic_issues.issue_id = issues.id)
I/O Timings: read=0.000 write=0.000
-> Index Scan using epics_pkey on public.epics (cost=0.42..1.05 rows=1 width=1339) (never executed)
Index Cond: (epics.id = epic_issues.epic_id)
Filter: (((epics.start_date IS NOT NULL) OR (epics.end_date IS NOT NULL)) AND ((epics.start_date IS NULL) OR (epics.start_date <= '2027-03-31'::date)) AND ((epics.end_date IS NULL) OR (epics.end_date >= '2026-09-01'::date)))
I/O Timings: read=0.000 write=0.000
-> Index Scan using namespaces_pkey on public.namespaces (cost=0.57..3.10 rows=1 width=4) (never executed)
Index Cond: (namespaces.id = epics.group_id)
Filter: ((namespaces.traversal_ids @> '{16947798}'::integer[]) AND ((namespaces.type)::text = 'Group'::text))
I/O Timings: read=0.000 write=0.000
Settings: random_page_cost = '1.5', seq_page_cost = '4', effective_cache_size = '472585MB', work_mem = '230MB', jit = 'off'
Query ID: -2832792539497670313Database Lab link: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/93493/commands/199480
Finder SQL, this MR, subgroup 16947798, milestone 19.6
SELECT "epics".*
FROM "epics"
WHERE "epics"."group_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{16947798}')))
AND ("epics"."start_date" IS NOT NULL
OR "epics"."end_date" IS NOT NULL)
AND ("epics"."start_date" IS NULL
OR "epics"."start_date" <= '2027-03-31')
AND ("epics"."end_date" IS NULL
OR "epics"."end_date" >= '2026-09-01')
AND "epics"."id" IN (
(SELECT "epic_issues"."epic_id"
FROM "epic_issues"
INNER JOIN "issues" ON "issues"."id" = "epic_issues"."issue_id"
WHERE "issues"."milestone_id" IN
(SELECT "milestones"."id"
FROM (
(SELECT "milestones".*
FROM "milestones"
WHERE "milestones"."project_id" IN
(SELECT "projects"."id"
FROM "projects"
LEFT JOIN project_features ON projects.id = project_features.project_id
WHERE "projects"."namespace_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{16947798}')))
AND ("project_features"."issues_access_level" IS NULL
OR "project_features"."issues_access_level" IN (20,
30)
OR ("project_features"."issues_access_level" = 10
AND EXISTS
(SELECT 1
FROM "project_authorizations"
WHERE "project_authorizations"."user_id" = 1
AND (project_authorizations.project_id = project_features.project_id)
AND (project_authorizations.access_level >= 10))))))
UNION ALL
(SELECT "milestones".*
FROM "milestones"
WHERE "milestones"."group_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND ("namespaces"."id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{16947798}')))
OR "namespaces"."id" = 1211)))) milestones
WHERE "milestones"."title" = '19.6'))
UNION ALL
(SELECT "epics"."id"
FROM "epics"
WHERE "epics"."issue_id" IN
(SELECT "issues"."id"
FROM "issues"
WHERE "issues"."milestone_id" IN
(SELECT "milestones"."id"
FROM (
(SELECT "milestones".*
FROM "milestones"
WHERE "milestones"."project_id" IN
(SELECT "projects"."id"
FROM "projects"
LEFT JOIN project_features ON projects.id = project_features.project_id
WHERE "projects"."namespace_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{16947798}')))
AND ("project_features"."issues_access_level" IS NULL
OR "project_features"."issues_access_level" IN (20,
30)
OR ("project_features"."issues_access_level" = 10
AND EXISTS
(SELECT 1
FROM "project_authorizations"
WHERE "project_authorizations"."user_id" = 1
AND (project_authorizations.project_id = project_features.project_id)
AND (project_authorizations.access_level >= 10))))))
UNION ALL
(SELECT "milestones".*
FROM "milestones"
WHERE "milestones"."group_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND ("namespaces"."id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (traversal_ids @> ('{16947798}')))
OR "namespaces"."id" = 1211)))) milestones
WHERE "milestones"."title" = '19.6'))))
ORDER BY "epics"."start_date" ASC NULLS LAST,
"epics"."id" DESC
LIMIT 51Warm plan, this MR, subgroup 16947798, milestone 19.6
Limit (cost=3297.61..3297.62 rows=1 width=1339) (actual time=2.545..2.558 rows=0 loops=1)
Buffers: shared hit=758
I/O Timings: read=0.000 write=0.000
-> Sort (cost=3297.61..3297.62 rows=1 width=1339) (actual time=2.544..2.557 rows=0 loops=1)
Sort Key: epics.start_date, epics.id DESC
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=758
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=3264.68..3297.60 rows=1 width=1339) (actual time=2.478..2.491 rows=0 loops=1)
Buffers: shared hit=752
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=3264.11..3291.35 rows=2 width=1339) (actual time=2.477..2.490 rows=0 loops=1)
Buffers: shared hit=752
I/O Timings: read=0.000 write=0.000
-> HashAggregate (cost=3263.69..3263.77 rows=8 width=4) (actual time=2.477..2.489 rows=0 loops=1)
Group Key: epic_issues.epic_id
Batches: 1 Memory Usage: 24kB
Buffers: shared hit=752
I/O Timings: read=0.000 write=0.000
-> Append (cost=1531.86..3263.67 rows=8 width=4) (actual time=2.475..2.487 rows=0 loops=1)
Buffers: shared hit=752
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1531.86..1631.32 rows=7 width=4) (actual time=1.370..1.378 rows=0 loops=1)
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1531.43..1547.03 rows=187 width=4) (actual time=1.370..1.377 rows=0 loops=1)
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Unique (cost=1530.86..1530.87 rows=2 width=4) (actual time=1.369..1.375 rows=0 loops=1)
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Sort (cost=1530.86..1530.86 rows=2 width=4) (actual time=1.368..1.375 rows=0 loops=1)
Sort Key: "*SELECT* 1".id
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Append (cost=2.13..1530.85 rows=2 width=4) (actual time=1.362..1.368 rows=0 loops=1)
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Subquery Scan on "*SELECT* 1" (cost=2.13..52.07 rows=1 width=4) (actual time=0.357..0.360 rows=0 loops=1)
Buffers: shared hit=232
I/O Timings: read=0.000 write=0.000
-> Nested Loop Semi Join (cost=2.13..52.06 rows=1 width=1176) (actual time=0.356..0.359 rows=0 loops=1)
Buffers: shared hit=232
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_milestones_on_title on public.milestones milestones_1 (cost=0.43..9.52 rows=5 width=8) (actual time=0.016..0.039 rows=19 loops=1)
Index Cond: ((milestones_1.title)::text = '19.6'::text)
Buffers: shared hit=22
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1.70..8.50 rows=1 width=4) (actual time=0.016..0.017 rows=0 loops=19)
Buffers: shared hit=210
I/O Timings: read=0.000 write=0.000
-> Nested Loop Left Join (cost=1.13..7.84 rows=1 width=8) (actual time=0.012..0.012 rows=1 loops=19)
Filter: ((project_features.issues_access_level IS NULL) OR (project_features.issues_access_level = ANY ('{20,30}'::integer[])) OR ((project_features.issues_access_level = 10) AND EXISTS(SubPlan 1)))
Buffers: shared hit=145
I/O Timings: read=0.000 write=0.000
-> Index Scan using idx_projects_on_repository_storage_last_repository_updated_at on public.projects (cost=0.56..3.58 rows=1 width=8) (actual time=0.005..0.005 rows=1 loops=19)
Index Cond: (projects.id = milestones_1.project_id)
Buffers: shared hit=71
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_project_features_on_project_id on public.project_features (cost=0.56..0.64 rows=1 width=8) (actual time=0.007..0.007 rows=1 loops=14)
Index Cond: (project_features.project_id = projects.id)
Buffers: shared hit=70
I/O Timings: read=0.000 write=0.000
SubPlan 1
-> Index Only Scan using index_project_authorizations_on_project_user_access_level on public.project_authorizations (cost=0.58..3.60 rows=1 width=0) (actual time=0.013..0.013 rows=0 loops=1)
Index Cond: ((project_authorizations.project_id = project_features.project_id) AND (project_authorizations.user_id = 1) AND (project_authorizations.access_level >= 10))
Heap Fetches: 0
Buffers: shared hit=4
I/O Timings: read=0.000 write=0.000
-> Index Scan using namespaces_pkey on public.namespaces namespaces_1 (cost=0.57..0.66 rows=1 width=4) (actual time=0.006..0.006 rows=0 loops=13)
Index Cond: (namespaces_1.id = projects.namespace_id)
Filter: ((namespaces_1.traversal_ids @> '{16947798}'::integer[]) AND ((namespaces_1.type)::text = 'Group'::text))
Rows Removed by Filter: 1
Buffers: shared hit=65
I/O Timings: read=0.000 write=0.000
-> Subquery Scan on "*SELECT* 2" (cost=292.45..1478.77 rows=1 width=4) (actual time=1.004..1.007 rows=0 loops=1)
Buffers: shared hit=144
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=292.45..1478.76 rows=1 width=1176) (actual time=1.004..1.006 rows=0 loops=1)
Buffers: shared hit=144
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_milestones_on_title on public.milestones milestones_2 (cost=0.43..9.52 rows=5 width=8) (actual time=0.010..0.022 rows=19 loops=1)
Index Cond: ((milestones_2.title)::text = '19.6'::text)
Buffers: shared hit=22
I/O Timings: read=0.000 write=0.000
-> Index Only Scan using index_namespaces_on_type_and_id on public.namespaces namespaces_2 (cost=292.02..293.85 rows=1 width=4) (actual time=0.051..0.052 rows=0 loops=19)
Index Cond: ((namespaces_2.type = 'Group'::text) AND (namespaces_2.id = milestones_2.group_id))
Heap Fetches: 0
Filter: ((ANY (namespaces_2.id = (hashed SubPlan 3).col1)) OR (namespaces_2.id = 1211))
Buffers: shared hit=122
I/O Timings: read=0.000 write=0.000
SubPlan 3
-> Bitmap Heap Scan on public.namespaces namespaces_5 (cost=173.44..291.26 rows=77 width=4) (actual time=0.918..0.920 rows=1 loops=1)
Recheck Cond: ((namespaces_5.traversal_ids @> '{16947798}'::integer[]) AND ((namespaces_5.type)::text = 'Group'::text))
Heap Blocks: exact=1
Buffers: shared hit=98
I/O Timings: read=0.000 write=0.000
-> Bitmap Index Scan on index_namespaces_on_traversal_ids_for_groups (cost=0.00..173.42 rows=77 width=0) (actual time=0.913..0.913 rows=1 loops=1)
Index Cond: (namespaces_5.traversal_ids @> '{16947798}'::integer[])
Buffers: shared hit=97
I/O Timings: read=0.000 write=0.000
-> Index Only Scan using index_issues_on_milestone_id_and_id on public.issues (cost=0.57..7.14 rows=94 width=8) (never executed)
Index Cond: (issues.milestone_id = "*SELECT* 1".id)
Heap Fetches: 0
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_epic_issues_on_issue_id on public.epic_issues (cost=0.43..0.45 rows=1 width=8) (never executed)
Index Cond: (epic_issues.issue_id = issues.id)
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1547.92..1632.31 rows=1 width=4) (actual time=1.103..1.107 rows=0 loops=1)
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> HashAggregate (cost=1547.50..1549.37 rows=187 width=4) (actual time=1.103..1.106 rows=0 loops=1)
Group Key: issues_1.id
Batches: 1 Memory Usage: 40kB
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1531.43..1547.03 rows=187 width=4) (actual time=1.100..1.103 rows=0 loops=1)
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Unique (cost=1530.86..1530.87 rows=2 width=4) (actual time=1.100..1.103 rows=0 loops=1)
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Sort (cost=1530.86..1530.86 rows=2 width=4) (actual time=1.099..1.102 rows=0 loops=1)
Sort Key: "*SELECT* 1_1".id
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Append (cost=2.13..1530.85 rows=2 width=4) (actual time=1.083..1.086 rows=0 loops=1)
Buffers: shared hit=376
I/O Timings: read=0.000 write=0.000
-> Subquery Scan on "*SELECT* 1_1" (cost=2.13..52.07 rows=1 width=4) (actual time=0.173..0.175 rows=0 loops=1)
Buffers: shared hit=232
I/O Timings: read=0.000 write=0.000
-> Nested Loop Semi Join (cost=2.13..52.06 rows=1 width=1176) (actual time=0.172..0.174 rows=0 loops=1)
Buffers: shared hit=232
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_milestones_on_title on public.milestones milestones_4 (cost=0.43..9.52 rows=5 width=8) (actual time=0.009..0.014 rows=19 loops=1)
Index Cond: ((milestones_4.title)::text = '19.6'::text)
Buffers: shared hit=22
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1.70..8.50 rows=1 width=4) (actual time=0.008..0.008 rows=0 loops=19)
Buffers: shared hit=210
I/O Timings: read=0.000 write=0.000
-> Nested Loop Left Join (cost=1.13..7.84 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=19)
Filter: ((project_features_1.issues_access_level IS NULL) OR (project_features_1.issues_access_level = ANY ('{20,30}'::integer[])) OR ((project_features_1.issues_access_level = 10) AND EXISTS(SubPlan 4)))
Buffers: shared hit=145
I/O Timings: read=0.000 write=0.000
-> Index Scan using idx_projects_on_repository_storage_last_repository_updated_at on public.projects projects_1 (cost=0.56..3.58 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=19)
Index Cond: (projects_1.id = milestones_4.project_id)
Buffers: shared hit=71
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_project_features_on_project_id on public.project_features project_features_1 (cost=0.56..0.64 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=14)
Index Cond: (project_features_1.project_id = projects_1.id)
Buffers: shared hit=70
I/O Timings: read=0.000 write=0.000
SubPlan 4
-> Index Only Scan using index_project_authorizations_on_project_user_access_level on public.project_authorizations project_authorizations_1 (cost=0.58..3.60 rows=1 width=0) (actual time=0.010..0.010 rows=0 loops=1)
Index Cond: ((project_authorizations_1.project_id = project_features_1.project_id) AND (project_authorizations_1.user_id = 1) AND (project_authorizations_1.access_level >= 10))
Heap Fetches: 0
Buffers: shared hit=4
I/O Timings: read=0.000 write=0.000
-> Index Scan using namespaces_pkey on public.namespaces namespaces_3 (cost=0.57..0.66 rows=1 width=4) (actual time=0.003..0.003 rows=0 loops=13)
Index Cond: (namespaces_3.id = projects_1.namespace_id)
Filter: ((namespaces_3.traversal_ids @> '{16947798}'::integer[]) AND ((namespaces_3.type)::text = 'Group'::text))
Rows Removed by Filter: 1
Buffers: shared hit=65
I/O Timings: read=0.000 write=0.000
-> Subquery Scan on "*SELECT* 2_1" (cost=292.45..1478.77 rows=1 width=4) (actual time=0.909..0.910 rows=0 loops=1)
Buffers: shared hit=144
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=292.45..1478.76 rows=1 width=1176) (actual time=0.909..0.909 rows=0 loops=1)
Buffers: shared hit=144
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_milestones_on_title on public.milestones milestones_5 (cost=0.43..9.52 rows=5 width=8) (actual time=0.009..0.016 rows=19 loops=1)
Index Cond: ((milestones_5.title)::text = '19.6'::text)
Buffers: shared hit=22
I/O Timings: read=0.000 write=0.000
-> Index Only Scan using index_namespaces_on_type_and_id on public.namespaces namespaces_4 (cost=292.02..293.85 rows=1 width=4) (actual time=0.047..0.047 rows=0 loops=19)
Index Cond: ((namespaces_4.type = 'Group'::text) AND (namespaces_4.id = milestones_5.group_id))
Heap Fetches: 0
Filter: ((ANY (namespaces_4.id = (hashed SubPlan 6).col1)) OR (namespaces_4.id = 1211))
Buffers: shared hit=122
I/O Timings: read=0.000 write=0.000
SubPlan 6
-> Bitmap Heap Scan on public.namespaces namespaces_6 (cost=173.44..291.26 rows=77 width=4) (actual time=0.851..0.852 rows=1 loops=1)
Recheck Cond: ((namespaces_6.traversal_ids @> '{16947798}'::integer[]) AND ((namespaces_6.type)::text = 'Group'::text))
Heap Blocks: exact=1
Buffers: shared hit=98
I/O Timings: read=0.000 write=0.000
-> Bitmap Index Scan on index_namespaces_on_traversal_ids_for_groups (cost=0.00..173.42 rows=77 width=0) (actual time=0.846..0.846 rows=1 loops=1)
Index Cond: (namespaces_6.traversal_ids @> '{16947798}'::integer[])
Buffers: shared hit=97
I/O Timings: read=0.000 write=0.000
-> Index Only Scan using index_issues_on_milestone_id_and_id on public.issues issues_1 (cost=0.57..7.14 rows=94 width=8) (never executed)
Index Cond: (issues_1.milestone_id = "*SELECT* 1_1".id)
Heap Fetches: 0
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_unique_epics_on_issue_id on public.epics epics_1 (cost=0.42..0.44 rows=1 width=8) (never executed)
Index Cond: (epics_1.issue_id = issues_1.id)
I/O Timings: read=0.000 write=0.000
-> Index Scan using epics_pkey on public.epics (cost=0.42..3.45 rows=1 width=1339) (never executed)
Index Cond: (epics.id = epic_issues.epic_id)
Filter: (((epics.start_date IS NOT NULL) OR (epics.end_date IS NOT NULL)) AND ((epics.start_date IS NULL) OR (epics.start_date <= '2027-03-31'::date)) AND ((epics.end_date IS NULL) OR (epics.end_date >= '2026-09-01'::date)))
I/O Timings: read=0.000 write=0.000
-> Index Scan using namespaces_pkey on public.namespaces (cost=0.57..3.10 rows=1 width=4) (never executed)
Index Cond: (namespaces.id = epics.group_id)
Filter: ((namespaces.traversal_ids @> '{16947798}'::integer[]) AND ((namespaces.type)::text = 'Group'::text))
I/O Timings: read=0.000 write=0.000
Settings: jit = 'off', random_page_cost = '1.5', seq_page_cost = '4', effective_cache_size = '472585MB', work_mem = '230MB'
Query ID: 4107360968742525420Database Lab link: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/93493/commands/199481
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
An AI coding assistant wrote this change. It also ran the new specs with and without the change, RuboCop on the seven changed Ruby files, the five changed spec files in full, the GraphQL documentation and introspection checks, the Database Lab plans, and the roadmap query on a test instance before and after.