Add a (candidate_id, name, id DESC) index on ml_candidate_metrics

What does this MR do and why?

This index makes reading the metric history of an ML run faster. for_history (Projects::Ml::MetricHistoryFinder) and the step columns of the run page in !272105 (merged) and !272230 (merged) read the values of one metric of one run. With this index, they read only the index entries of that metric. On the run page, the last 100 values of each metric take about 10 ms per page with the index, against 1.3 s with the old index for the densest run. After the read switch of !270985 (merged), the metric order of experiment runs reads ml_candidate_latest_metrics, so this index no longer serves it.

The index is added with add_concurrent_index in a post-deployment migration. It builds in about two minutes on Database Lab, so no asynchronous index is needed. There is no feature flag. After the post-deployment migration has run on GitLab.com, a revert does not run down, so removing the index needs a new migration with remove_concurrent_index_by_name.

Merge this MR only after the read switch of !270985 (merged) (MR 3 of its plan) is at 100% on GitLab.com. With this index, PostgreSQL plans the DISTINCT ON metric order of experiments above 50,000 runs as a full scan of the new index: 1.9 to 2.4 min instead of 16 to 25 s on the largest experiment. The read switch orders by the latest value in ml_candidate_latest_metrics for every experiment size, so that query stops running. On self-managed, the index and the read switch must ship in the same release, so this MR merges in the milestone where the read flag is removed or enabled by default.

Context for reviewers and agents
  • The query that uses the index is the LATERAL branch of Ml::Candidate.order_by_metric (app/models/ml/candidate.rb), used by Projects::Ml::CandidateFinder for the experiment page (HTML and CSV) and for MLflow runs/search with order_by=metrics.<name>. It shipped in !263900 (merged), and its feature flag was removed in !269564 (merged).
  • This MR keeps Projects::Ml::CandidateFinder::LATERAL_METRIC_ORDER_MAX_CANDIDATES (50,000) and the DISTINCT ON query above it. Today, one experiment on GitLab.com (about 911,000 runs) has more runs than the limit. The read switch after !270985 (merged) replaces both branches of the metric order: its (experiment_id, name, value DESC, candidate_id DESC) index reads one page of rows (0.8 ms on the largest experiment in the plans of that MR). MR 4 of that plan removes the limit, the DISTINCT ON branch and the lateral branch.
  • The new index makes ml_candidate_metrics larger than 10 GB (5.9 GB heap, 2.96 GB new index, 11 GB in total on Database Lab), so db/docs/ml_candidate_metrics.yml changes from small to medium.
  • index_ml_candidate_metrics_on_candidate_id stays. The new index starts with candidate_id, but removing the old one changes the plans of the latest_metrics preload and the run page reads. That is a later MR, after this index exists on every installation (step 5 of #635116 (closed)). spec/support/helpers/database/duplicate_indexes.yml lists the pair, so the schema spec accepts the duplicate until then.
  • https://gitlab.com/gitlab-org/gitlab/-/work_items/640899 (run page reads the latest value per metric) depends on this index.

References

Screenshots or screen recordings

No UI change.

How to set up and validate locally

  1. Check out the branch and run bin/rails db:migrate.
  2. Run gdk psql -c '\d ml_candidate_metrics'. Expect: index_ml_candidate_metrics_on_candidate_id_name_id_desc btree (candidate_id, name, id DESC).
  3. Open an experiment with runs that log metrics, for example http://gdk.test:3000/<group>/<project>/-/ml/experiments/<iid>, and sort the runs by a metric. Expect: the same runs in the same order as on master.
  4. Run bin/rails db:migrate:down:main VERSION=20261118091913. Expect: the index is gone and db/structure.sql matches master.

Database

All plans ran in one Database Lab session on 2026-11-20 (session 100333): first on a clone without the new index, then on a reset clone after CREATE INDEX and ANALYZE. Each cell links to its plan and shows the execution time and the shared buffers (hit + read), and the WAL for writes. First runs depend on what the clone has cached, so compare the second runs.

Query (Database Lab, gitlab-production-main) Before: first run Before: second run After: first run After: second run Planning time, second run (before / after)
Lateral metric order, experiment A (88 runs, many metric rows per run) 40.5 s, 145k 38.1 s, 145k 97 ms, 516 0.9 ms, 516 1.7 / 1.6 ms
Lateral metric order, experiment B (15,200 runs) 6.2 s, 249k 173 ms, 249k 4.4 s, 91k 71 ms, 91k 1.6 / 1.7 ms
Lateral metric order, experiment C (911,000 runs) 1.33 min, 4.56 M 4.9 s, 4.56 M 1.15 min, 5.47 M 5.2 s, 5.47 M 1.7 / 2.0 ms
DISTINCT ON metric order, experiment C (the path above 50,000 runs) 25.1 s, 4.42 M 16.0 s, 4.42 M 2.4 min, 4.85 M 1.9 min, 4.85 M 1.7 / 45 ms
Metric history of the run with the most metric rows (for_history) 2.3 s, 13k 56 ms, 13k 7.1 s, 37k 65 ms, 37k 0.9 / 0.9 ms
latest_metrics preload for a page of 31 runs (candidate_id IN (...)) 4.9 s, 57.8k 4.1 s, 57.8k 17.1 s, 57.8k 4.1 s, 57.8k 1.4 / 1.5 ms
most_recent_for_candidate 144 ms, 12.4k 148 ms, 12.4k 0.9 / 0.8 ms (first run)
Ml::DeleteExperimentRunsService metric batch (for_candidates(...).limit(10_000).delete_all) 83 ms, 60.9k, 4.3 MB WAL 33 ms, 60.5k, 540 kB WAL 442 ms, 63.1k, 24.5 MB WAL 52 ms, 69.2k, 540 kB WAL 2.4 / 1.8 ms
Foreign key cascade: delete the 614,560 metric rows of the run with the most metric rows 1.5 s, 638k, 128.8 MB WAL 367 ms, 627k, 33.2 MB WAL 1.2 s, 638k, 128.8 MB WAL 487 ms, 627k, 33.2 MB WAL 0.6 / 0.7 ms
Insert of 1,000 metrics into one run (MLflow log-batch maximum) 141 ms, 19.5k, 418 kB WAL 38 ms, 19.5k, 396 kB WAL 120 ms, 23.6k, 768 kB WAL 48 ms, 23.5k, 491 kB WAL 0.2 / 0.1 ms

Three consecutive Ml::DeleteExperimentRunsService metric batches on experiment A, each committed before the next, with no vacuum in between:

Batch Before After
1 34 ms, 60.5k, 540 kB WAL 49 ms, 69.2k, 540 kB WAL
2 65 ms, 61.2k, 3.5 MB WAL 134 ms, 76.9k, 12.5 MB WAL
3 55 ms, 61.0k, 2.9 MB WAL 63 ms, 79.2k, 1.7 MB WAL
Total 153 ms, 183k, 7.0 MB WAL 246 ms, 225k, 14.7 MB WAL
  • Experiment B reads 91k buffers instead of 249k with the index (71 ms instead of 173 ms on the second run). Its first run after the index reads index pages that no query had read yet.
  • Experiment A's second run before the index stays at 38 s, because the clone does not keep its 145k buffers in cache.
  • With the index, the DISTINCT ON query is a full scan of the new index: 1.9 min instead of 16 s on the second run. It stops running when the read switch is at 100%, and this MR merges after that.
  • The metric history query now uses the new index: 37k buffers instead of 13k, and a similar time on the second run.
  • The latest_metrics preload and most_recent_for_candidate keep the old index, with the same buffers before and after. Their first runs differ only in what the clone had cached.
  • A DELETE adds no index entries, so the cascade delete writes the same WAL (614,560 records) with and without the new index. It keeps the old index.
  • An insert of 1,000 metrics writes one more WAL record per row for the new index: 6,062 records instead of 5,060 and 491 kB instead of 396 kB on the second run, in 48 ms instead of 38 ms.
  • The batch delete of Ml::DeleteExperimentRunsService (app/services/ml/delete_experiment_runs_service.rb) switches from an index scan on the old index to an index-only scan on the new index. The batch has no ORDER BY, so with the new index the LIMIT 10000 takes rows spread over more heap pages. Over three consecutive batches it reads 225k buffers instead of 183k and writes 14.7 MB of WAL instead of 7.0 MB. Most of that WAL is full-page images, which depend on checkpoint timing. The 10,000-row limit bounds each batch.
  • Index build: CREATE INDEX took 1.1 to 2.2 min on the clone (six builds). add_concurrent_index takes longer, but stays well under the 20-minute limit for a post-deployment migration.
  • Plans use LIMIT 31 (the experiment page size). The plan output is below, one collapsed block per plan.

Readers that filter on candidate_id only

The plans ran on Database Lab on 2026-11-23, with and without the new index (sessions 102918 and 103157). "Densest runs" are the runs with the most metric rows. The densest run has 614,560 rows, and the 31 densest runs hold 12.0 M rows in total. Each cell shows the time and the shared buffers. Compare the second runs.

Reader Index before / after Second run, before Second run, after
GraphQL MlCandidate.metrics (candidate_id = ? ORDER BY id DESC LIMIT 101), runs with 6 and 2,505 metrics candidate_id / candidate_id 0.8 ms, 10 and 1.6 ms, 96 1.6 ms, 10 and 1.8 ms, 96
Same, densest run primary key backward / primary key backward more than 5 min 2.28 min, 11.2 M
for_history, densest run candidate_id / new 48 ms, 13.1k 56 ms, 37.4k
most_recent_for_candidate (LIMIT 1001), densest run candidate_id / candidate_id 164 ms, 12.4k 157 ms, 12.4k
latest_metrics, one run candidate_id / candidate_id 1.12 s, 12.4k 1.28 s, 12.4k
latest_metrics preload, 31 densest runs candidate_id + sort / new 24.8 s, 327k 11.8 s, 10.7 M
latest_metrics preload, 200 densest runs candidate_id + sort / new 74.7 s, 746k 36.3 s, 19.4 M
latest_metrics preload, 1,000 densest runs candidate_id + sort / new 82.2 s, 1.17 M 39.2 s, 24.2 M
  • The GraphQL connection on the densest run scans the primary key backwards with and without the index. The index does not change that plan.
  • The latest_metrics preload for 31 or more runs moves to the new index. Its second run takes about half the time, but its first run for the 31 densest runs is slower: 1.81 min instead of 1.08 min. This does not reach GitLab.com or self-managed: the read switch moves this preload to ml_candidate_latest_metrics too, and this MR merges after the read switch.
  • The 200- and 1,000-run IN-lists are too long for the Joe CLI. A function on the clone ran them, so they show no plan link: Joe commands 618207 and 618213 before, 618300 and 618306 after.
Migration output (test database)
main: == [advisory_lock_connection] object_id: 53688, pg_backend_pid: 49214
main: == 20261118091913 AddIndexMlCandidateMetricsOnCandidateIdNameIdDesc: reverting 
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0133s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0003s
main: -- index_name_exists?(:ml_candidate_metrics, "index_ml_candidate_metrics_on_candidate_id_name_id_desc")
main:    -> 0.0004s
main: -- remove_index(:ml_candidate_metrics, {algorithm: :concurrently, name: "index_ml_candidate_metrics_on_candidate_id_name_id_desc"})
main:    -> 0.0011s
main: == 20261118091913 AddIndexMlCandidateMetricsOnCandidateIdNameIdDesc: reverted (0.0447s) 

main: == [advisory_lock_connection] object_id: 53688, pg_backend_pid: 49214
main: == [advisory_lock_connection] object_id: 53672, pg_backend_pid: 49303
main: == 20261118091913 AddIndexMlCandidateMetricsOnCandidateIdNameIdDesc: migrating 
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0150s
main: -- index_exists?(:ml_candidate_metrics, [:candidate_id, :name, :id], {order: {id: :desc}, name: "index_ml_candidate_metrics_on_candidate_id_name_id_desc", algorithm: :concurrently})
main:    -> 0.0017s
main: -- add_index(:ml_candidate_metrics, [:candidate_id, :name, :id], {order: {id: :desc}, name: "index_ml_candidate_metrics_on_candidate_id_name_id_desc", algorithm: :concurrently})
main:    -> 0.0013s
main: == 20261118091913 AddIndexMlCandidateMetricsOnCandidateIdNameIdDesc: migrated (0.0321s) 

main: == [advisory_lock_connection] object_id: 53672, pg_backend_pid: 49303

Query plans

The tables above link each plan. The SQL and the plan output below replace literals with placeholders.

SQL of the planned queries

Lateral metric order (experiments A, B and C):

SELECT ml_candidates.*, latest.value AS metric_value
FROM ml_candidates
INNER JOIN LATERAL (
  SELECT ml_candidate_metrics.candidate_id, ml_candidate_metrics.value
  FROM ml_candidate_metrics
  WHERE ml_candidate_metrics.name = '<metric>'
    AND ml_candidate_metrics.candidate_id = ml_candidates.id
  ORDER BY ml_candidate_metrics.id DESC
  LIMIT 1
) latest ON latest.candidate_id = ml_candidates.id
WHERE ml_candidates.experiment_id = <experiment_id>
ORDER BY latest.value DESC NULLS LAST, ml_candidates.id DESC
LIMIT 31

DISTINCT ON metric order (experiment C):

SELECT ml_candidates.*, latest.value AS metric_value
FROM ml_candidates
INNER JOIN (
  SELECT DISTINCT ON (candidate_id, name) *
  FROM ml_candidate_metrics
  WHERE ml_candidate_metrics.name = '<metric>'
  ORDER BY candidate_id, name, id DESC
) latest ON latest.candidate_id = ml_candidates.id
WHERE ml_candidates.experiment_id = <experiment_c_id>
ORDER BY latest.value DESC NULLS LAST, ml_candidates.id DESC
LIMIT 31

Metric history (for_history):

SELECT ml_candidate_metrics.* FROM ml_candidate_metrics
WHERE ml_candidate_metrics.candidate_id = <run_id> AND ml_candidate_metrics.name = '<metric>'
ORDER BY ml_candidate_metrics.step ASC, ml_candidate_metrics.tracked_at ASC

latest_metrics preload:

SELECT DISTINCT ON (candidate_id, name) * FROM ml_candidate_metrics
WHERE ml_candidate_metrics.candidate_id IN (<page of 31 run ids>)
ORDER BY candidate_id, name, id DESC

most_recent_for_candidate:

SELECT ml_candidate_metrics.* FROM (
  SELECT ml_candidate_metrics.* FROM ml_candidate_metrics WHERE ml_candidate_metrics.candidate_id = <run_id> OFFSET 0
) ml_candidate_metrics
ORDER BY ml_candidate_metrics.id DESC
LIMIT 1001

Ml::DeleteExperimentRunsService metric batch:

DELETE FROM ml_candidate_metrics WHERE (ml_candidate_metrics.id) IN (
  SELECT ml_candidate_metrics.id FROM ml_candidate_metrics
  WHERE ml_candidate_metrics.candidate_id IN (
    SELECT ml_candidates.id FROM ml_candidates
    WHERE ml_candidates.experiment_id = <experiment_a_id> AND ml_candidates.eid >= '<first eid of the batch>'
  )
  LIMIT 10000
)

Foreign key cascade of a run delete:

DELETE FROM ml_candidate_metrics WHERE candidate_id = <run_id>

Insert of 1,000 metrics. The application sends a VALUES list through insert_all; the plan uses generate_series to keep the statement short:

INSERT INTO ml_candidate_metrics (candidate_id, name, value, tracked_at, step, created_at, updated_at)
SELECT <run_id>, 'metric_' || g, g * 0.5, <timestamp> + g, g, now(), now()
FROM generate_series(1, 1000) g
ON CONFLICT DO NOTHING
Lateral, experiment A, before (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207045

 Limit  (cost=5885.41..5885.42 rows=1 width=149) (actual time=40458.797..40458.808 rows=31 loops=1)
   Buffers: shared hit=18798 read=126080 dirtied=1 written=3
   WAL: records=2 fpi=1 bytes=8293
   I/O Timings: read=39344.503 write=0.248
   ->  Sort  (cost=5885.41..5885.42 rows=1 width=149) (actual time=40458.796..40458.803 rows=31 loops=1)
         Sort Key: latest.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 37kB
         Buffers: shared hit=18798 read=126080 dirtied=1 written=3
         WAL: records=2 fpi=1 bytes=8293
         I/O Timings: read=39344.503 write=0.248
         ->  Nested Loop  (cost=95.97..5885.40 rows=1 width=149) (actual time=17.855..40458.082 rows=64 loops=1)
               Buffers: shared hit=18792 read=126080 dirtied=1 written=3
               WAL: records=2 fpi=1 bytes=8293
               I/O Timings: read=39344.503 write=0.248
               ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..55.85 rows=61 width=141) (actual time=4.792..69.817 rows=88 loops=1)
                     Index Cond: (ml_candidates.experiment_id = <experiment_a_id>)
                     Buffers: shared hit=24 read=70 dirtied=1
                     WAL: records=2 fpi=1 bytes=8293
                     I/O Timings: read=68.466 write=0.000
               ->  Subquery Scan on latest  (cost=95.54..95.56 rows=1 width=16) (actual time=458.953..458.954 rows=1 loops=88)
                     Filter: (ml_candidates.id = latest.candidate_id)
                     Buffers: shared hit=18768 read=126010 written=3
                     I/O Timings: read=39276.036 write=0.248
                     ->  Limit  (cost=95.54..95.54 rows=1 width=24) (actual time=458.952..458.952 rows=1 loops=88)
                           Buffers: shared hit=18768 read=126010 written=3
                           I/O Timings: read=39276.036 write=0.248
                           ->  Sort  (cost=95.54..95.58 rows=14 width=24) (actual time=458.949..458.949 rows=1 loops=88)
                                 Sort Key: ml_candidate_metrics.id DESC
                                 Sort Method: top-N heapsort  Memory: 25kB
                                 Buffers: shared hit=18768 read=126010 written=3
                                 I/O Timings: read=39276.036 write=0.248
                                 ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..95.47 rows=14 width=24) (actual time=7.354..458.562 rows=731 loops=88)
                                       Index Cond: (ml_candidate_metrics.candidate_id = ml_candidates.id)
                                       Filter: (ml_candidate_metrics.name = '<metric>'::text)
                                       Rows Removed by Filter: 54837
                                       Buffers: shared hit=18768 read=126010 written=3
                                       I/O Timings: read=39276.036 write=0.248
Planning Time: 1.577 ms
Execution Time: 40458.901 ms
Lateral, experiment A, before (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207054

 Limit  (cost=5885.41..5885.42 rows=1 width=149) (actual time=38088.090..38088.099 rows=31 loops=1)
   Buffers: shared hit=25376 read=119502
   I/O Timings: read=36905.674 write=0.000
   ->  Sort  (cost=5885.41..5885.42 rows=1 width=149) (actual time=38088.089..38088.095 rows=31 loops=1)
         Sort Key: latest.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 37kB
         Buffers: shared hit=25376 read=119502
         I/O Timings: read=36905.674 write=0.000
         ->  Nested Loop  (cost=95.97..5885.40 rows=1 width=149) (actual time=11.696..38087.886 rows=64 loops=1)
               Buffers: shared hit=25370 read=119502
               I/O Timings: read=36905.674 write=0.000
               ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..55.85 rows=61 width=141) (actual time=2.047..41.340 rows=88 loops=1)
                     Index Cond: (ml_candidates.experiment_id = <experiment_a_id>)
                     Buffers: shared hit=42 read=52
                     I/O Timings: read=40.820 write=0.000
               ->  Subquery Scan on latest  (cost=95.54..95.56 rows=1 width=16) (actual time=432.344..432.344 rows=1 loops=88)
                     Filter: (ml_candidates.id = latest.candidate_id)
                     Buffers: shared hit=25328 read=119450
                     I/O Timings: read=36864.854 write=0.000
                     ->  Limit  (cost=95.54..95.54 rows=1 width=24) (actual time=432.342..432.342 rows=1 loops=88)
                           Buffers: shared hit=25328 read=119450
                           I/O Timings: read=36864.854 write=0.000
                           ->  Sort  (cost=95.54..95.58 rows=14 width=24) (actual time=432.339..432.339 rows=1 loops=88)
                                 Sort Key: ml_candidate_metrics.id DESC
                                 Sort Method: top-N heapsort  Memory: 25kB
                                 Buffers: shared hit=25328 read=119450
                                 I/O Timings: read=36864.854 write=0.000
                                 ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..95.47 rows=14 width=24) (actual time=2.915..431.987 rows=731 loops=88)
                                       Index Cond: (ml_candidate_metrics.candidate_id = ml_candidates.id)
                                       Filter: (ml_candidate_metrics.name = '<metric>'::text)
                                       Rows Removed by Filter: 54837
                                       Buffers: shared hit=25328 read=119450
                                       I/O Timings: read=36864.854 write=0.000
Planning Time: 1.691 ms
Execution Time: 38088.191 ms
Lateral, experiment A, after (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207104

 Limit  (cost=143.65..143.66 rows=1 width=149) (actual time=96.822..96.831 rows=31 loops=1)
   Buffers: shared hit=253 read=263 dirtied=1
   WAL: records=2 fpi=1 bytes=8293
   I/O Timings: read=94.238 write=0.000
   ->  Sort  (cost=143.65..143.66 rows=1 width=149) (actual time=96.821..96.826 rows=31 loops=1)
         Sort Key: latest.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 37kB
         Buffers: shared hit=253 read=263 dirtied=1
         WAL: records=2 fpi=1 bytes=8293
         I/O Timings: read=94.238 write=0.000
         ->  Nested Loop  (cost=0.99..143.64 rows=1 width=149) (actual time=3.030..96.671 rows=64 loops=1)
               Buffers: shared hit=247 read=263 dirtied=1
               WAL: records=2 fpi=1 bytes=8293
               I/O Timings: read=94.238 write=0.000
               ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..55.85 rows=61 width=141) (actual time=2.714..85.339 rows=88 loops=1)
                     Index Cond: (ml_candidates.experiment_id = <experiment_a_id>)
                     Buffers: shared hit=25 read=69 dirtied=1
                     WAL: records=2 fpi=1 bytes=8293
                     I/O Timings: read=84.479 write=0.000
               ->  Subquery Scan on latest  (cost=0.56..1.43 rows=1 width=16) (actual time=0.127..0.127 rows=1 loops=88)
                     Filter: (ml_candidates.id = latest.candidate_id)
                     Buffers: shared hit=222 read=194
                     I/O Timings: read=9.759 write=0.000
                     ->  Limit  (cost=0.56..1.42 rows=1 width=24) (actual time=0.126..0.126 rows=1 loops=88)
                           Buffers: shared hit=222 read=194
                           I/O Timings: read=9.759 write=0.000
                           ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..12.49 rows=14 width=24) (actual time=0.125..0.125 rows=1 loops=88)
                                 Index Cond: ((ml_candidate_metrics.candidate_id = ml_candidates.id) AND (ml_candidate_metrics.name = '<metric>'::text))
                                 Buffers: shared hit=222 read=194
                                 I/O Timings: read=9.759 write=0.000
Planning Time: 1.682 ms
Execution Time: 96.92 ms
Lateral, experiment A, after (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207105

 Limit  (cost=143.65..143.66 rows=1 width=149) (actual time=0.823..0.829 rows=31 loops=1)
   Buffers: shared hit=516
   I/O Timings: read=0.000 write=0.000
   ->  Sort  (cost=143.65..143.66 rows=1 width=149) (actual time=0.823..0.825 rows=31 loops=1)
         Sort Key: latest.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 37kB
         Buffers: shared hit=516
         I/O Timings: read=0.000 write=0.000
         ->  Nested Loop  (cost=0.99..143.64 rows=1 width=149) (actual time=0.037..0.763 rows=64 loops=1)
               Buffers: shared hit=510
               I/O Timings: read=0.000 write=0.000
               ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..55.85 rows=61 width=141) (actual time=0.019..0.133 rows=88 loops=1)
                     Index Cond: (ml_candidates.experiment_id = <experiment_a_id>)
                     Buffers: shared hit=94
                     I/O Timings: read=0.000 write=0.000
               ->  Subquery Scan on latest  (cost=0.56..1.43 rows=1 width=16) (actual time=0.007..0.007 rows=1 loops=88)
                     Filter: (ml_candidates.id = latest.candidate_id)
                     Buffers: shared hit=416
                     I/O Timings: read=0.000 write=0.000
                     ->  Limit  (cost=0.56..1.42 rows=1 width=24) (actual time=0.007..0.007 rows=1 loops=88)
                           Buffers: shared hit=416
                           I/O Timings: read=0.000 write=0.000
                           ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..12.49 rows=14 width=24) (actual time=0.006..0.006 rows=1 loops=88)
                                 Index Cond: ((ml_candidate_metrics.candidate_id = ml_candidates.id) AND (ml_candidate_metrics.name = '<metric>'::text))
                                 Buffers: shared hit=416
                                 I/O Timings: read=0.000 write=0.000
Planning Time: 1.587 ms
Execution Time: 0.907 ms
Lateral, experiment B, before (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207060

 Limit  (cost=1439416.94..1439417.01 rows=31 width=149) (actual time=6208.599..6208.605 rows=31 loops=1)
   Buffers: shared hit=238765 read=10269 dirtied=1
   WAL: records=1 fpi=1 bytes=8061
   I/O Timings: read=5919.328 write=0.000
   ->  Sort  (cost=1439416.94..1439417.12 rows=75 width=149) (actual time=6208.598..6208.601 rows=31 loops=1)
         Sort Key: latest.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 37kB
         Buffers: shared hit=238765 read=10269 dirtied=1
         WAL: records=1 fpi=1 bytes=8061
         I/O Timings: read=5919.328 write=0.000
         ->  Nested Loop  (cost=95.91..1439414.70 rows=75 width=149) (actual time=10.844..6199.842 rows=15199 loops=1)
               Buffers: shared hit=238759 read=10269 dirtied=1
               WAL: records=1 fpi=1 bytes=8061
               I/O Timings: read=5919.328 write=0.000
               ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..10410.11 rows=14962 width=141) (actual time=1.617..686.410 rows=15200 loops=1)
                     Index Cond: (ml_candidates.experiment_id = <experiment_b_id>)
                     Buffers: shared hit=14256 read=1018 dirtied=1
                     WAL: records=1 fpi=1 bytes=8061
                     I/O Timings: read=666.664 write=0.000
               ->  Subquery Scan on latest  (cost=95.48..95.50 rows=1 width=16) (actual time=0.362..0.362 rows=1 loops=15200)
                     Filter: (ml_candidates.id = latest.candidate_id)
                     Buffers: shared hit=224503 read=9251
                     I/O Timings: read=5252.664 write=0.000
                     ->  Limit  (cost=95.48..95.49 rows=1 width=24) (actual time=0.362..0.362 rows=1 loops=15200)
                           Buffers: shared hit=224503 read=9251
                           I/O Timings: read=5252.664 write=0.000
                           ->  Sort  (cost=95.48..95.49 rows=1 width=24) (actual time=0.361..0.361 rows=1 loops=15200)
                                 Sort Key: ml_candidate_metrics.id DESC
                                 Sort Method: quicksort  Memory: 25kB
                                 Buffers: shared hit=224503 read=9251
                                 I/O Timings: read=5252.664 write=0.000
                                 ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..95.47 rows=1 width=24) (actual time=0.194..0.360 rows=1 loops=15200)
                                       Index Cond: (ml_candidate_metrics.candidate_id = ml_candidates.id)
                                       Filter: (ml_candidate_metrics.name = '<metric>'::text)
                                       Rows Removed by Filter: 12
                                       Buffers: shared hit=224503 read=9251
                                       I/O Timings: read=5252.664 write=0.000
Planning Time: 11.882 ms
Execution Time: 6208.697 ms
Lateral, experiment B, before (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207064

 Limit  (cost=1439416.94..1439417.01 rows=31 width=149) (actual time=172.527..172.534 rows=31 loops=1)
   Buffers: shared hit=249034
   I/O Timings: read=0.000 write=0.000
   ->  Sort  (cost=1439416.94..1439417.12 rows=75 width=149) (actual time=172.526..172.530 rows=31 loops=1)
         Sort Key: latest.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 37kB
         Buffers: shared hit=249034
         I/O Timings: read=0.000 write=0.000
         ->  Nested Loop  (cost=95.91..1439414.70 rows=75 width=149) (actual time=0.093..166.447 rows=15199 loops=1)
               Buffers: shared hit=249028
               I/O Timings: read=0.000 write=0.000
               ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..10410.11 rows=14962 width=141) (actual time=0.029..11.964 rows=15200 loops=1)
                     Index Cond: (ml_candidates.experiment_id = <experiment_b_id>)
                     Buffers: shared hit=15274
                     I/O Timings: read=0.000 write=0.000
               ->  Subquery Scan on latest  (cost=95.48..95.50 rows=1 width=16) (actual time=0.010..0.010 rows=1 loops=15200)
                     Filter: (ml_candidates.id = latest.candidate_id)
                     Buffers: shared hit=233754
                     I/O Timings: read=0.000 write=0.000
                     ->  Limit  (cost=95.48..95.49 rows=1 width=24) (actual time=0.010..0.010 rows=1 loops=15200)
                           Buffers: shared hit=233754
                           I/O Timings: read=0.000 write=0.000
                           ->  Sort  (cost=95.48..95.49 rows=1 width=24) (actual time=0.009..0.009 rows=1 loops=15200)
                                 Sort Key: ml_candidate_metrics.id DESC
                                 Sort Method: quicksort  Memory: 25kB
                                 Buffers: shared hit=233754
                                 I/O Timings: read=0.000 write=0.000
                                 ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..95.47 rows=1 width=24) (actual time=0.005..0.009 rows=1 loops=15200)
                                       Index Cond: (ml_candidate_metrics.candidate_id = ml_candidates.id)
                                       Filter: (ml_candidate_metrics.name = '<metric>'::text)
                                       Rows Removed by Filter: 12
                                       Buffers: shared hit=233754
                                       I/O Timings: read=0.000 write=0.000
Planning Time: 1.607 ms
Execution Time: 172.637 ms
Lateral, experiment B, after (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207107

 Limit  (cost=64387.76..64387.84 rows=31 width=149) (actual time=4407.713..4407.720 rows=31 loops=1)
   Buffers: shared hit=81189 read=10090 dirtied=1
   WAL: records=1 fpi=1 bytes=8061
   I/O Timings: read=4253.801 write=0.000
   ->  Sort  (cost=64387.76..64387.95 rows=75 width=149) (actual time=4407.712..4407.715 rows=31 loops=1)
         Sort Key: latest.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 37kB
         Buffers: shared hit=81189 read=10090 dirtied=1
         WAL: records=1 fpi=1 bytes=8061
         I/O Timings: read=4253.801 write=0.000
         ->  Nested Loop  (cost=0.99..64385.53 rows=75 width=149) (actual time=3.638..4397.295 rows=15199 loops=1)
               Buffers: shared hit=81183 read=10090 dirtied=1
               WAL: records=1 fpi=1 bytes=8061
               I/O Timings: read=4253.801 write=0.000
               ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..10410.11 rows=14962 width=141) (actual time=1.678..644.002 rows=15200 loops=1)
                     Index Cond: (ml_candidates.experiment_id = <experiment_b_id>)
                     Buffers: shared hit=14261 read=1013 dirtied=1
                     WAL: records=1 fpi=1 bytes=8061
                     I/O Timings: read=613.197 write=0.000
               ->  Subquery Scan on latest  (cost=0.56..3.60 rows=1 width=16) (actual time=0.246..0.246 rows=1 loops=15200)
                     Filter: (ml_candidates.id = latest.candidate_id)
                     Buffers: shared hit=66922 read=9077
                     I/O Timings: read=3640.605 write=0.000
                     ->  Limit  (cost=0.56..3.58 rows=1 width=24) (actual time=0.246..0.246 rows=1 loops=15200)
                           Buffers: shared hit=66922 read=9077
                           I/O Timings: read=3640.605 write=0.000
                           ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..3.58 rows=1 width=24) (actual time=0.246..0.246 rows=1 loops=15200)
                                 Index Cond: ((ml_candidate_metrics.candidate_id = ml_candidates.id) AND (ml_candidate_metrics.name = '<metric>'::text))
                                 Buffers: shared hit=66922 read=9077
                                 I/O Timings: read=3640.605 write=0.000
Planning Time: 1.705 ms
Execution Time: 4407.815 ms
Lateral, experiment B, after (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207110

 Limit  (cost=64387.76..64387.84 rows=31 width=149) (actual time=70.805..70.810 rows=31 loops=1)
   Buffers: shared hit=91279
   I/O Timings: read=0.000 write=0.000
   ->  Sort  (cost=64387.76..64387.95 rows=75 width=149) (actual time=70.804..70.806 rows=31 loops=1)
         Sort Key: latest.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 37kB
         Buffers: shared hit=91279
         I/O Timings: read=0.000 write=0.000
         ->  Nested Loop  (cost=0.99..64385.53 rows=75 width=149) (actual time=0.048..65.404 rows=15199 loops=1)
               Buffers: shared hit=91273
               I/O Timings: read=0.000 write=0.000
               ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..10410.11 rows=14962 width=141) (actual time=0.029..9.923 rows=15200 loops=1)
                     Index Cond: (ml_candidates.experiment_id = <experiment_b_id>)
                     Buffers: shared hit=15274
                     I/O Timings: read=0.000 write=0.000
               ->  Subquery Scan on latest  (cost=0.56..3.60 rows=1 width=16) (actual time=0.003..0.003 rows=1 loops=15200)
                     Filter: (ml_candidates.id = latest.candidate_id)
                     Buffers: shared hit=75999
                     I/O Timings: read=0.000 write=0.000
                     ->  Limit  (cost=0.56..3.58 rows=1 width=24) (actual time=0.003..0.003 rows=1 loops=15200)
                           Buffers: shared hit=75999
                           I/O Timings: read=0.000 write=0.000
                           ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..3.58 rows=1 width=24) (actual time=0.003..0.003 rows=1 loops=15200)
                                 Index Cond: ((ml_candidate_metrics.candidate_id = ml_candidates.id) AND (ml_candidate_metrics.name = '<metric>'::text))
                                 Buffers: shared hit=75999
                                 I/O Timings: read=0.000 write=0.000
Planning Time: 1.711 ms
Execution Time: 70.905 ms
Lateral, experiment C, before (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207074

 Limit  (cost=87162580.04..87162580.12 rows=31 width=149) (actual time=79602.425..79602.431 rows=31 loops=1)
   Buffers: shared hit=4461067 read=99917 dirtied=239
   WAL: records=260 fpi=239 bytes=1923791
   I/O Timings: read=72037.166 write=0.000
   ->  Sort  (cost=87162580.04..87162591.43 rows=4556 width=149) (actual time=79602.424..79602.427 rows=31 loops=1)
         Sort Key: latest.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 39kB
         Buffers: shared hit=4461067 read=99917 dirtied=239
         WAL: records=260 fpi=239 bytes=1923791
         I/O Timings: read=72037.166 write=0.000
         ->  Nested Loop  (cost=95.98..87162444.40 rows=4556 width=149) (actual time=8.229..79143.231 rows=910901 loops=1)
               Buffers: shared hit=4461061 read=99917 dirtied=239
               WAL: records=260 fpi=239 bytes=1923791
               I/O Timings: read=72037.166 write=0.000
               ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..78013.46 rows=911102 width=141) (actual time=4.267..20928.225 rows=911053 loops=1)
                     Index Cond: (ml_candidates.experiment_id = <experiment_c_id>)
                     Buffers: shared hit=890846 read=25879 dirtied=239
                     WAL: records=260 fpi=239 bytes=1923791
                     I/O Timings: read=19534.782 write=0.000
               ->  Subquery Scan on latest  (cost=95.56..95.57 rows=1 width=16) (actual time=0.063..0.063 rows=1 loops=911053)
                     Filter: (ml_candidates.id = latest.candidate_id)
                     Buffers: shared hit=3570215 read=74038
                     I/O Timings: read=52502.384 write=0.000
                     ->  Limit  (cost=95.56..95.56 rows=1 width=24) (actual time=0.063..0.063 rows=1 loops=911053)
                           Buffers: shared hit=3570215 read=74038
                           I/O Timings: read=52502.384 write=0.000
                           ->  Sort  (cost=95.56..95.60 rows=17 width=24) (actual time=0.063..0.063 rows=1 loops=911053)
                                 Sort Key: ml_candidate_metrics.id DESC
                                 Sort Method: quicksort  Memory: 25kB
                                 Buffers: shared hit=3570215 read=74038
                                 I/O Timings: read=52502.384 write=0.000
                                 ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..95.47 rows=17 width=24) (actual time=0.062..0.062 rows=1 loops=911053)
                                       Index Cond: (ml_candidate_metrics.candidate_id = ml_candidates.id)
                                       Filter: (ml_candidate_metrics.name = '<metric>'::text)
                                       Buffers: shared hit=3570215 read=74038
                                       I/O Timings: read=52502.384 write=0.000
Planning Time: 2.346 ms
Execution Time: 79602.549 ms
Lateral, experiment C, before (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207076

 Limit  (cost=87162580.04..87162580.12 rows=31 width=149) (actual time=4940.765..4940.771 rows=31 loops=1)
   Buffers: shared hit=4560981 read=3
   I/O Timings: read=0.320 write=0.000
   ->  Sort  (cost=87162580.04..87162591.43 rows=4556 width=149) (actual time=4940.763..4940.767 rows=31 loops=1)
         Sort Key: latest.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 39kB
         Buffers: shared hit=4560981 read=3
         I/O Timings: read=0.320 write=0.000
         ->  Nested Loop  (cost=95.98..87162444.40 rows=4556 width=149) (actual time=0.076..4571.788 rows=910901 loops=1)
               Buffers: shared hit=4560975 read=3
               I/O Timings: read=0.320 write=0.000
               ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..78013.46 rows=911102 width=141) (actual time=0.052..921.293 rows=911053 loops=1)
                     Index Cond: (ml_candidates.experiment_id = <experiment_c_id>)
                     Buffers: shared hit=916725
                     I/O Timings: read=0.000 write=0.000
               ->  Subquery Scan on latest  (cost=95.56..95.57 rows=1 width=16) (actual time=0.004..0.004 rows=1 loops=911053)
                     Filter: (ml_candidates.id = latest.candidate_id)
                     Buffers: shared hit=3644250 read=3
                     I/O Timings: read=0.320 write=0.000
                     ->  Limit  (cost=95.56..95.56 rows=1 width=24) (actual time=0.003..0.003 rows=1 loops=911053)
                           Buffers: shared hit=3644250 read=3
                           I/O Timings: read=0.320 write=0.000
                           ->  Sort  (cost=95.56..95.60 rows=17 width=24) (actual time=0.003..0.003 rows=1 loops=911053)
                                 Sort Key: ml_candidate_metrics.id DESC
                                 Sort Method: quicksort  Memory: 25kB
                                 Buffers: shared hit=3644250 read=3
                                 I/O Timings: read=0.320 write=0.000
                                 ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..95.47 rows=17 width=24) (actual time=0.003..0.003 rows=1 loops=911053)
                                       Index Cond: (ml_candidate_metrics.candidate_id = ml_candidates.id)
                                       Filter: (ml_candidate_metrics.name = '<metric>'::text)
                                       Buffers: shared hit=3644250 read=3
                                       I/O Timings: read=0.320 write=0.000
Planning Time: 1.66 ms
Execution Time: 4940.863 ms
Lateral, experiment C, after (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207118

 Limit  (cost=1362577.66..1362577.74 rows=31 width=149) (actual time=68725.028..68725.034 rows=31 loops=1)
   Buffers: shared hit=5361874 read=109970 dirtied=239 written=3040
   WAL: records=260 fpi=239 bytes=1923791
   I/O Timings: read=61730.479 write=256.890
   ->  Sort  (cost=1362577.66..1362589.05 rows=4556 width=149) (actual time=68725.027..68725.030 rows=31 loops=1)
         Sort Key: latest.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 39kB
         Buffers: shared hit=5361874 read=109970 dirtied=239 written=3040
         WAL: records=260 fpi=239 bytes=1923791
         I/O Timings: read=61730.479 write=256.890
         ->  Nested Loop  (cost=0.99..1362442.03 rows=4556 width=149) (actual time=6.810..68273.022 rows=910901 loops=1)
               Buffers: shared hit=5361868 read=109970 dirtied=239 written=3040
               WAL: records=260 fpi=239 bytes=1923791
               I/O Timings: read=61730.479 write=256.890
               ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..78013.46 rows=911102 width=141) (actual time=3.940..21068.654 rows=911053 loops=1)
                     Index Cond: (ml_candidates.experiment_id = <experiment_c_id>)
                     Buffers: shared hit=890871 read=25854 dirtied=239 written=857
                     WAL: records=260 fpi=239 bytes=1923791
                     I/O Timings: read=19701.196 write=84.658
               ->  Subquery Scan on latest  (cost=0.56..1.40 rows=1 width=16) (actual time=0.051..0.051 rows=1 loops=911053)
                     Filter: (ml_candidates.id = latest.candidate_id)
                     Buffers: shared hit=4470997 read=84116 written=2183
                     I/O Timings: read=42029.283 write=172.232
                     ->  Limit  (cost=0.56..1.39 rows=1 width=24) (actual time=0.051..0.051 rows=1 loops=911053)
                           Buffers: shared hit=4470997 read=84116 written=2183
                           I/O Timings: read=42029.283 write=172.232
                           ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..14.54 rows=17 width=24) (actual time=0.051..0.051 rows=1 loops=911053)
                                 Index Cond: ((ml_candidate_metrics.candidate_id = ml_candidates.id) AND (ml_candidate_metrics.name = '<metric>'::text))
                                 Buffers: shared hit=4470997 read=84116 written=2183
                                 I/O Timings: read=42029.283 write=172.232
Planning Time: 1.669 ms
Execution Time: 68725.135 ms
Lateral, experiment C, after (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207206

 Limit  (cost=1362577.66..1362577.74 rows=31 width=149) (actual time=5232.688..5232.694 rows=31 loops=1)
   Buffers: shared hit=5460667 read=11177
   I/O Timings: read=215.845 write=0.000
   ->  Sort  (cost=1362577.66..1362589.05 rows=4556 width=149) (actual time=5232.687..5232.690 rows=31 loops=1)
         Sort Key: latest.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 39kB
         Buffers: shared hit=5460667 read=11177
         I/O Timings: read=215.845 write=0.000
         ->  Nested Loop  (cost=0.99..1362442.03 rows=4556 width=149) (actual time=0.192..4852.703 rows=910901 loops=1)
               Buffers: shared hit=5460661 read=11177
               I/O Timings: read=215.845 write=0.000
               ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..78013.46 rows=911102 width=141) (actual time=0.173..1002.189 rows=911053 loops=1)
                     Index Cond: (ml_candidates.experiment_id = <experiment_c_id>)
                     Buffers: shared hit=912990 read=3735
                     I/O Timings: read=55.998 write=0.000
               ->  Subquery Scan on latest  (cost=0.56..1.40 rows=1 width=16) (actual time=0.004..0.004 rows=1 loops=911053)
                     Filter: (ml_candidates.id = latest.candidate_id)
                     Buffers: shared hit=4547671 read=7442
                     I/O Timings: read=159.847 write=0.000
                     ->  Limit  (cost=0.56..1.39 rows=1 width=24) (actual time=0.004..0.004 rows=1 loops=911053)
                           Buffers: shared hit=4547671 read=7442
                           I/O Timings: read=159.847 write=0.000
                           ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..14.54 rows=17 width=24) (actual time=0.003..0.003 rows=1 loops=911053)
                                 Index Cond: ((ml_candidate_metrics.candidate_id = ml_candidates.id) AND (ml_candidate_metrics.name = '<metric>'::text))
                                 Buffers: shared hit=4547671 read=7442
                                 I/O Timings: read=159.847 write=0.000
Planning Time: 2.049 ms
Execution Time: 5232.786 ms
DISTINCT ON, experiment C, before (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207078

 Limit  (cost=3573107.06..3573107.13 rows=31 width=149) (actual time=25097.709..25116.088 rows=31 loops=1)
   Buffers: shared hit=3736684 read=680378 dirtied=6850
   WAL: records=6850 fpi=6850 bytes=52828822
   I/O Timings: read=60093.431 write=0.000
   ->  Sort  (cost=3573107.06..3573206.90 rows=39937 width=149) (actual time=25097.706..25116.083 rows=31 loops=1)
         Sort Key: ml_candidate_metrics.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 41kB
         Buffers: shared hit=3736684 read=680378 dirtied=6850
         WAL: records=6850 fpi=6850 bytes=52828822
         I/O Timings: read=60093.431 write=0.000
         ->  Nested Loop  (cost=3396995.36..3571918.09 rows=39937 width=149) (actual time=21730.275..24817.360 rows=910901 loops=1)
               Buffers: shared hit=3736681 read=680378 dirtied=6850
               WAL: records=6850 fpi=6850 bytes=52828822
               I/O Timings: read=60093.431 write=0.000
               ->  Unique  (cost=3396994.94..3504833.17 rows=53496 width=114) (actual time=21727.604..22170.207 rows=910901 loops=1)
                     Buffers: shared hit=96029 read=677426 dirtied=6850
                     WAL: records=6850 fpi=6850 bytes=52828822
                     I/O Timings: read=58972.525 write=0.000
                     ->  Gather Merge  (cost=3396994.94..3502567.02 rows=906459 width=114) (actual time=21727.601..21964.823 rows=910951 loops=1)
                           Workers Planned: 2
                           Workers Launched: 2
                           Buffers: shared hit=96029 read=677426 dirtied=6850
                           WAL: records=6850 fpi=6850 bytes=52828822
                           I/O Timings: read=58972.525 write=0.000
                           ->  Sort  (cost=3395994.91..3396939.14 rows=377691 width=114) (actual time=21721.850..21752.552 rows=303650 loops=3)
                                 Sort Key: ml_candidate_metrics.candidate_id, ml_candidate_metrics.id DESC
                                 Sort Method: quicksort  Memory: 38091kB
                                 Buffers: shared hit=96029 read=677426 dirtied=6850
                                 WAL: records=6850 fpi=6850 bytes=52828822
                                 I/O Timings: read=58972.525 write=0.000
                                 ->  Parallel Seq Scan on public.ml_candidate_metrics  (cost=0.00..3361007.80 rows=377691 width=114) (actual time=599.524..21618.558 rows=303650 loops=3)
                                       Filter: (ml_candidate_metrics.name = '<metric>'::text)
                                       Rows Removed by Filter: 16817908
                                       Buffers: shared hit=95929 read=677426 dirtied=6850
                                       WAL: records=6850 fpi=6850 bytes=52828822
                                       I/O Timings: read=58972.525 write=0.000
               ->  Index Scan using ml_candidates_pkey on public.ml_candidates  (cost=0.43..1.24 rows=1 width=141) (actual time=0.003..0.003 rows=1 loops=910901)
                     Index Cond: (ml_candidates.id = ml_candidate_metrics.candidate_id)
                     Filter: (ml_candidates.experiment_id = <experiment_c_id>)
                     Buffers: shared hit=3640652 read=2952
                     I/O Timings: read=1120.906 write=0.000
Planning Time: 1.616 ms
Execution Time: 25117.909 ms
DISTINCT ON, experiment C, before (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207079

 Limit  (cost=3573107.06..3573107.13 rows=31 width=149) (actual time=16009.733..16027.741 rows=31 loops=1)
   Buffers: shared hit=3737377 read=679685
   I/O Timings: read=37141.916 write=0.000
   ->  Sort  (cost=3573107.06..3573206.90 rows=39937 width=149) (actual time=16009.732..16027.736 rows=31 loops=1)
         Sort Key: ml_candidate_metrics.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 41kB
         Buffers: shared hit=3737377 read=679685
         I/O Timings: read=37141.916 write=0.000
         ->  Nested Loop  (cost=3396995.36..3571918.09 rows=39937 width=149) (actual time=14049.052..15762.523 rows=910901 loops=1)
               Buffers: shared hit=3737374 read=679685
               I/O Timings: read=37141.916 write=0.000
               ->  Unique  (cost=3396994.94..3504833.17 rows=53496 width=114) (actual time=14049.022..14438.185 rows=910901 loops=1)
                     Buffers: shared hit=93770 read=679685
                     I/O Timings: read=37141.916 write=0.000
                     ->  Gather Merge  (cost=3396994.94..3502567.02 rows=906459 width=114) (actual time=14049.020..14252.450 rows=910951 loops=1)
                           Workers Planned: 2
                           Workers Launched: 2
                           Buffers: shared hit=93770 read=679685
                           I/O Timings: read=37141.916 write=0.000
                           ->  Sort  (cost=3395994.91..3396939.14 rows=377691 width=114) (actual time=14040.423..14065.359 rows=303650 loops=3)
                                 Sort Key: ml_candidate_metrics.candidate_id, ml_candidate_metrics.id DESC
                                 Sort Method: quicksort  Memory: 39688kB
                                 Buffers: shared hit=93770 read=679685
                                 I/O Timings: read=37141.916 write=0.000
                                 ->  Parallel Seq Scan on public.ml_candidate_metrics  (cost=0.00..3361007.80 rows=377691 width=114) (actual time=609.662..13934.244 rows=303650 loops=3)
                                       Filter: (ml_candidate_metrics.name = '<metric>'::text)
                                       Rows Removed by Filter: 16817908
                                       Buffers: shared hit=93670 read=679685
                                       I/O Timings: read=37141.916 write=0.000
               ->  Index Scan using ml_candidates_pkey on public.ml_candidates  (cost=0.43..1.24 rows=1 width=141) (actual time=0.001..0.001 rows=1 loops=910901)
                     Index Cond: (ml_candidates.id = ml_candidate_metrics.candidate_id)
                     Filter: (ml_candidates.experiment_id = <experiment_c_id>)
                     Buffers: shared hit=3643604
                     I/O Timings: read=0.000 write=0.000
Planning Time: 1.692 ms
Execution Time: 16031.704 ms
DISTINCT ON, experiment C, after (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207180

 Limit  (cost=1459207.20..1459207.28 rows=31 width=149) (actual time=141202.946..141202.952 rows=31 loops=1)
   Buffers: shared hit=4383047 read=463146
   I/O Timings: read=135650.491 write=0.000
   ->  Sort  (cost=1459207.20..1459306.94 rows=39894 width=149) (actual time=141202.944..141202.947 rows=31 loops=1)
         Sort Key: ml_candidate_metrics.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 41kB
         Buffers: shared hit=4383047 read=463146
         I/O Timings: read=135650.491 write=0.000
         ->  Nested Loop  (cost=0.99..1458019.52 rows=39894 width=149) (actual time=39347.143..140855.777 rows=910901 loops=1)
               Buffers: shared hit=4383041 read=463146
               I/O Timings: read=135650.491 write=0.000
               ->  Unique  (cost=0.56..1390961.13 rows=53438 width=114) (actual time=39343.749..132300.918 rows=910901 loops=1)
                     Buffers: shared hit=760841 read=441742
                     I/O Timings: read=128892.170 write=0.000
                     ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..1388655.73 rows=922161 width=114) (actual time=39343.746..132038.603 rows=910951 loops=1)
                           Index Cond: (ml_candidate_metrics.name = '<metric>'::text)
                           Buffers: shared hit=760841 read=441742
                           I/O Timings: read=128892.170 write=0.000
               ->  Index Scan using ml_candidates_pkey on public.ml_candidates  (cost=0.43..1.24 rows=1 width=141) (actual time=0.009..0.009 rows=1 loops=910901)
                     Index Cond: (ml_candidates.id = ml_candidate_metrics.candidate_id)
                     Filter: (ml_candidates.experiment_id = <experiment_c_id>)
                     Buffers: shared hit=3622200 read=21404
                     I/O Timings: read=6758.321 write=0.000
Planning Time: 1.891 ms
Execution Time: 141203.061 ms
DISTINCT ON, experiment C, after (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207184

 Limit  (cost=1459207.20..1459207.28 rows=31 width=149) (actual time=111338.690..111338.697 rows=31 loops=1)
   Buffers: shared hit=4370885 read=475308
   I/O Timings: read=106093.897 write=0.000
   ->  Sort  (cost=1459207.20..1459306.94 rows=39894 width=149) (actual time=111338.687..111338.691 rows=31 loops=1)
         Sort Key: ml_candidate_metrics.value DESC NULLS LAST, ml_candidates.id DESC
         Sort Method: top-N heapsort  Memory: 41kB
         Buffers: shared hit=4370885 read=475308
         I/O Timings: read=106093.897 write=0.000
         ->  Nested Loop  (cost=0.99..1458019.52 rows=39894 width=149) (actual time=33190.181..111016.400 rows=910901 loops=1)
               Buffers: shared hit=4370879 read=475308
               I/O Timings: read=106093.897 write=0.000
               ->  Unique  (cost=0.56..1390961.13 rows=53438 width=114) (actual time=33186.673..102122.737 rows=910901 loops=1)
                     Buffers: shared hit=750809 read=451774
                     I/O Timings: read=98867.317 write=0.000
                     ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..1388655.73 rows=922161 width=114) (actual time=33186.670..101883.404 rows=910951 loops=1)
                           Index Cond: (ml_candidate_metrics.name = '<metric>'::text)
                           Buffers: shared hit=750809 read=451774
                           I/O Timings: read=98867.317 write=0.000
               ->  Index Scan using ml_candidates_pkey on public.ml_candidates  (cost=0.43..1.24 rows=1 width=141) (actual time=0.009..0.009 rows=1 loops=910901)
                     Index Cond: (ml_candidates.id = ml_candidate_metrics.candidate_id)
                     Filter: (ml_candidates.experiment_id = <experiment_c_id>)
                     Buffers: shared hit=3620070 read=23534
                     I/O Timings: read=7226.580 write=0.000
Planning Time: 45.32 ms
Execution Time: 111338.819 ms
Metric history, before (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207039

 Gather Merge  (cost=54850.10..55796.57 rows=8112 width=114) (actual time=2241.803..2253.023 rows=44360 loops=1)
   Workers Planned: 2
   Workers Launched: 2
   Buffers: shared hit=680 read=12443
   I/O Timings: read=6367.339 write=0.000
   ->  Sort  (cost=53850.08..53860.22 rows=4056 width=114) (actual time=2225.636..2226.550 rows=14787 loops=3)
         Sort Key: ml_candidate_metrics.step, ml_candidate_metrics.tracked_at
         Sort Method: quicksort  Memory: 2104kB
         Buffers: shared hit=680 read=12443
         I/O Timings: read=6367.339 write=0.000
         ->  Parallel Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..53607.00 rows=4056 width=114) (actual time=3.413..2219.604 rows=14787 loops=3)
               Index Cond: (ml_candidate_metrics.candidate_id = <run_id>)
               Filter: (ml_candidate_metrics.name = '<metric>'::text)
               Rows Removed by Filter: 190067
               Buffers: shared hit=642 read=12443
               I/O Timings: read=6367.339 write=0.000
Planning Time: 0.879 ms
Execution Time: 2255.221 ms
Metric history, before (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207081

 Gather Merge  (cost=54850.10..55796.57 rows=8112 width=114) (actual time=42.290..53.803 rows=44360 loops=1)
   Workers Planned: 2
   Workers Launched: 2
   Buffers: shared hit=13115
   I/O Timings: read=0.000 write=0.000
   ->  Sort  (cost=53850.08..53860.22 rows=4056 width=114) (actual time=39.151..39.977 rows=14787 loops=3)
         Sort Key: ml_candidate_metrics.step, ml_candidate_metrics.tracked_at
         Sort Method: quicksort  Memory: 2140kB
         Buffers: shared hit=13115
         I/O Timings: read=0.000 write=0.000
         ->  Parallel Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..53607.00 rows=4056 width=114) (actual time=0.056..35.922 rows=14787 loops=3)
               Index Cond: (ml_candidate_metrics.candidate_id = <run_id>)
               Filter: (ml_candidate_metrics.name = '<metric>'::text)
               Rows Removed by Filter: 190067
               Buffers: shared hit=13077
               I/O Timings: read=0.000 write=0.000
Planning Time: 0.885 ms
Execution Time: 55.881 ms
Metric history, after (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207186

 Sort  (cost=7813.95..7838.61 rows=9866 width=114) (actual time=7103.012..7105.348 rows=44360 loops=1)
   Sort Key: ml_candidate_metrics.step, ml_candidate_metrics.tracked_at
   Sort Method: quicksort  Memory: 6735kB
   Buffers: shared hit=25317 read=12037
   I/O Timings: read=7001.059 write=0.000
   ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..7159.43 rows=9866 width=114) (actual time=2.431..7081.520 rows=44360 loops=1)
         Index Cond: ((ml_candidate_metrics.candidate_id = <run_id>) AND (ml_candidate_metrics.name = '<metric>'::text))
         Buffers: shared hit=25311 read=12037
         I/O Timings: read=7001.059 write=0.000
Planning Time: 19.311 ms
Execution Time: 7107.784 ms
Metric history, after (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207187

 Sort  (cost=7813.95..7838.61 rows=9866 width=114) (actual time=60.756..62.829 rows=44360 loops=1)
   Sort Key: ml_candidate_metrics.step, ml_candidate_metrics.tracked_at
   Sort Method: quicksort  Memory: 6735kB
   Buffers: shared hit=37354
   I/O Timings: read=0.000 write=0.000
   ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..7159.43 rows=9866 width=114) (actual time=0.032..46.761 rows=44360 loops=1)
         Index Cond: ((ml_candidate_metrics.candidate_id = <run_id>) AND (ml_candidate_metrics.name = '<metric>'::text))
         Buffers: shared hit=37348
         I/O Timings: read=0.000 write=0.000
Planning Time: 0.923 ms
Execution Time: 64.994 ms
latest_metrics preload, page of 31 runs, before (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207082

 Unique  (cost=4.97..281421.81 rows=1803305 width=114) (actual time=2.213..4894.622 rows=763 loops=1)
   Buffers: shared hit=15380 read=42432
   I/O Timings: read=1025.114 write=0.000
   ->  Incremental Sort  (cost=4.97..270552.93 rows=2173776 width=114) (actual time=2.212..4583.200 rows=2145497 loops=1)
         Sort Key: ml_candidate_metrics.candidate_id, ml_candidate_metrics.name, ml_candidate_metrics.id DESC
         Presorted Key: ml_candidate_metrics.candidate_id
         Full-sort Groups: 31  Sort Method: quicksort  Average Memory: 32kB  Peak Memory: 32kB
         Pre-sorted Groups: 31  Sort Method: quicksort  Average Memory: 23043kB  Peak Memory: 96721kB
         Buffers: shared hit=15380 read=42432
         I/O Timings: read=1025.114 write=0.000
         ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..184220.68 rows=2173776 width=114) (actual time=0.879..1382.345 rows=2145497 loops=1)
               Index Cond: (ml_candidate_metrics.candidate_id = ANY ('{<page of 31 run ids>}'::bigint[]))
               Buffers: shared hit=15374 read=42432
               I/O Timings: read=1025.114 write=0.000
Planning Time: 1.426 ms
Execution Time: 4894.747 ms
latest_metrics preload, page of 31 runs, before (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207083

 Unique  (cost=4.97..281421.81 rows=1803305 width=114) (actual time=5.758..4135.286 rows=763 loops=1)
   Buffers: shared hit=38116 read=19696
   I/O Timings: read=298.051 write=0.000
   ->  Incremental Sort  (cost=4.97..270552.93 rows=2173776 width=114) (actual time=5.757..3817.883 rows=2145497 loops=1)
         Sort Key: ml_candidate_metrics.candidate_id, ml_candidate_metrics.name, ml_candidate_metrics.id DESC
         Presorted Key: ml_candidate_metrics.candidate_id
         Full-sort Groups: 31  Sort Method: quicksort  Average Memory: 32kB  Peak Memory: 32kB
         Pre-sorted Groups: 31  Sort Method: quicksort  Average Memory: 23043kB  Peak Memory: 96721kB
         Buffers: shared hit=38116 read=19696
         I/O Timings: read=298.051 write=0.000
         ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..184220.68 rows=2173776 width=114) (actual time=0.209..621.458 rows=2145497 loops=1)
               Index Cond: (ml_candidate_metrics.candidate_id = ANY ('{<page of 31 run ids>}'::bigint[]))
               Buffers: shared hit=38110 read=19696
               I/O Timings: read=298.051 write=0.000
Planning Time: 1.434 ms
Execution Time: 4135.413 ms
latest_metrics preload, page of 31 runs, after (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207188

 Unique  (cost=4.96..280597.13 rows=1803203 width=114) (actual time=45.672..17143.189 rows=763 loops=1)
   Buffers: shared hit=14445 read=43367
   I/O Timings: read=12816.782 write=0.000
   ->  Incremental Sort  (cost=4.96..269728.40 rows=2173745 width=114) (actual time=45.671..16804.298 rows=2145497 loops=1)
         Sort Key: ml_candidate_metrics.candidate_id, ml_candidate_metrics.name, ml_candidate_metrics.id DESC
         Presorted Key: ml_candidate_metrics.candidate_id
         Full-sort Groups: 31  Sort Method: quicksort  Average Memory: 32kB  Peak Memory: 32kB
         Pre-sorted Groups: 31  Sort Method: quicksort  Average Memory: 23043kB  Peak Memory: 96721kB
         Buffers: shared hit=14445 read=43367
         I/O Timings: read=12816.782 write=0.000
         ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..183381.75 rows=2173745 width=114) (actual time=3.280..13284.629 rows=2145497 loops=1)
               Index Cond: (ml_candidate_metrics.candidate_id = ANY ('{<page of 31 run ids>}'::bigint[]))
               Buffers: shared hit=14439 read=43367
               I/O Timings: read=12816.782 write=0.000
Planning Time: 1.38 ms
Execution Time: 17143.331 ms
latest_metrics preload, page of 31 runs, after (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207189

 Unique  (cost=4.96..280597.13 rows=1803203 width=114) (actual time=0.774..4052.645 rows=763 loops=1)
   Buffers: shared hit=57812
   I/O Timings: read=0.000 write=0.000
   ->  Incremental Sort  (cost=4.96..269728.40 rows=2173745 width=114) (actual time=0.774..3710.986 rows=2145497 loops=1)
         Sort Key: ml_candidate_metrics.candidate_id, ml_candidate_metrics.name, ml_candidate_metrics.id DESC
         Presorted Key: ml_candidate_metrics.candidate_id
         Full-sort Groups: 31  Sort Method: quicksort  Average Memory: 32kB  Peak Memory: 32kB
         Pre-sorted Groups: 31  Sort Method: quicksort  Average Memory: 23043kB  Peak Memory: 96721kB
         Buffers: shared hit=57812
         I/O Timings: read=0.000 write=0.000
         ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..183381.75 rows=2173745 width=114) (actual time=0.039..337.865 rows=2145497 loops=1)
               Index Cond: (ml_candidate_metrics.candidate_id = ANY ('{<page of 31 run ids>}'::bigint[]))
               Buffers: shared hit=57806
               I/O Timings: read=0.000 write=0.000
Planning Time: 1.531 ms
Execution Time: 4052.788 ms
most_recent_for_candidate, before

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207084

 Limit  (cost=90807.95..90810.45 rows=1001 width=114) (actual time=143.372..143.492 rows=1001 loops=1)
   Buffers: shared hit=12431
   I/O Timings: read=0.000 write=0.000
   ->  Sort  (cost=90807.95..92367.67 rows=623886 width=114) (actual time=143.370..143.417 rows=1001 loops=1)
         Sort Key: ml_candidate_metrics.id DESC
         Sort Method: top-N heapsort  Memory: 297kB
         Buffers: shared hit=12431
         I/O Timings: read=0.000 write=0.000
         ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..56596.46 rows=623886 width=114) (actual time=0.057..88.323 rows=614560 loops=1)
               Index Cond: (ml_candidate_metrics.candidate_id = <run_id>)
               Buffers: shared hit=12428
               I/O Timings: read=0.000 write=0.000
Planning Time: 0.867 ms
Execution Time: 143.594 ms
most_recent_for_candidate, after

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207190

 Limit  (cost=89146.24..89148.75 rows=1001 width=114) (actual time=148.001..148.132 rows=1001 loops=1)
   Buffers: shared hit=12431
   I/O Timings: read=0.000 write=0.000
   ->  Sort  (cost=89146.24..90685.89 rows=615858 width=114) (actual time=148.000..148.050 rows=1001 loops=1)
         Sort Key: ml_candidate_metrics.id DESC
         Sort Method: top-N heapsort  Memory: 297kB
         Buffers: shared hit=12431
         I/O Timings: read=0.000 write=0.000
         ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..55374.97 rows=615858 width=114) (actual time=0.071..90.477 rows=614560 loops=1)
               Index Cond: (ml_candidate_metrics.candidate_id = <run_id>)
               Buffers: shared hit=12428
               I/O Timings: read=0.000 write=0.000
Planning Time: 0.844 ms
Execution Time: 148.245 ms
DeleteExperimentRunsService metric batch, before (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207086

 Delete on public.ml_candidate_metrics  (cost=4204.77..13393.75 rows=0 width=0) (actual time=82.424..82.428 rows=0 loops=1)
   Buffers: shared hit=60847 read=91 dirtied=458
   WAL: records=10000 fpi=456 bytes=4259640
   I/O Timings: read=46.753 write=0.000
   ->  Nested Loop  (cost=4204.77..13393.75 rows=2568 width=38) (actual time=13.305..73.903 rows=10000 loops=1)
         Buffers: shared hit=50395 read=89
         I/O Timings: read=45.377 write=0.000
         ->  HashAggregate  (cost=4204.21..4229.89 rows=2568 width=40) (actual time=10.701..12.876 rows=10000 loops=1)
               Group Key: "ANY_subquery".id
               Batches: 1  Memory Usage: 1425kB
               Buffers: shared hit=478 read=6
               I/O Timings: read=2.734 write=0.000
               ->  Subquery Scan on "ANY_subquery"  (cost=0.87..4197.79 rows=2568 width=40) (actual time=1.418..8.223 rows=10000 loops=1)
                     Buffers: shared hit=478 read=6
                     I/O Timings: read=2.734 write=0.000
                     ->  Limit  (cost=0.87..4172.11 rows=2568 width=8) (actual time=1.408..6.756 rows=10000 loops=1)
                           Buffers: shared hit=478 read=6
                           I/O Timings: read=2.734 write=0.000
                           ->  Nested Loop  (cost=0.87..4172.11 rows=2568 width=8) (actual time=1.407..5.987 rows=10000 loops=1)
                                 Buffers: shared hit=478 read=6
                                 I/O Timings: read=2.734 write=0.000
                                 ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..56.00 rows=61 width=8) (actual time=1.378..1.474 rows=3 loops=1)
                                       Index Cond: ((ml_candidates.experiment_id = <experiment_a_id>) AND (ml_candidates.eid >= '<first eid of the batch>'::uuid))
                                       Buffers: shared hit=5 read=4
                                       I/O Timings: read=1.424 write=0.000
                                 ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics ml_candidate_metrics_1  (cost=0.44..57.88 rows=960 width=16) (actual time=0.461..1.157 rows=3333 loops=3)
                                       Index Cond: (ml_candidate_metrics_1.candidate_id = ml_candidates.id)
                                       Buffers: shared hit=473 read=2
                                       I/O Timings: read=1.310 write=0.000
         ->  Index Scan using ml_candidate_metrics_pkey on public.ml_candidate_metrics  (cost=0.56..3.57 rows=1 width=14) (actual time=0.006..0.006 rows=1 loops=10000)
               Index Cond: (ml_candidate_metrics.id = "ANY_subquery".id)
               Buffers: shared hit=49917 read=83
               I/O Timings: read=42.642 write=0.000
Planning Time: 6.749 ms
Execution Time: 82.672 ms
DeleteExperimentRunsService metric batch, before (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207087

 Delete on public.ml_candidate_metrics  (cost=4204.77..13393.75 rows=0 width=0) (actual time=32.731..32.734 rows=0 loops=1)
   Buffers: shared hit=60484
   WAL: records=10000 fpi=0 bytes=540000
   I/O Timings: read=0.000 write=0.000
   ->  Nested Loop  (cost=4204.77..13393.75 rows=2568 width=38) (actual time=10.598..28.616 rows=10000 loops=1)
         Buffers: shared hit=50484
         I/O Timings: read=0.000 write=0.000
         ->  HashAggregate  (cost=4204.21..4229.89 rows=2568 width=40) (actual time=10.583..12.181 rows=10000 loops=1)
               Group Key: "ANY_subquery".id
               Batches: 1  Memory Usage: 1425kB
               Buffers: shared hit=484
               I/O Timings: read=0.000 write=0.000
               ->  Subquery Scan on "ANY_subquery"  (cost=0.87..4197.79 rows=2568 width=40) (actual time=0.119..7.655 rows=10000 loops=1)
                     Buffers: shared hit=484
                     I/O Timings: read=0.000 write=0.000
                     ->  Limit  (cost=0.87..4172.11 rows=2568 width=8) (actual time=0.108..5.860 rows=10000 loops=1)
                           Buffers: shared hit=484
                           I/O Timings: read=0.000 write=0.000
                           ->  Nested Loop  (cost=0.87..4172.11 rows=2568 width=8) (actual time=0.107..4.958 rows=10000 loops=1)
                                 Buffers: shared hit=484
                                 I/O Timings: read=0.000 write=0.000
                                 ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..56.00 rows=61 width=8) (actual time=0.047..0.067 rows=3 loops=1)
                                       Index Cond: ((ml_candidates.experiment_id = <experiment_a_id>) AND (ml_candidates.eid >= '<first eid of the batch>'::uuid))
                                       Buffers: shared hit=9
                                       I/O Timings: read=0.000 write=0.000
                                 ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics ml_candidate_metrics_1  (cost=0.44..57.88 rows=960 width=16) (actual time=0.037..1.242 rows=3333 loops=3)
                                       Index Cond: (ml_candidate_metrics_1.candidate_id = ml_candidates.id)
                                       Buffers: shared hit=475
                                       I/O Timings: read=0.000 write=0.000
         ->  Index Scan using ml_candidate_metrics_pkey on public.ml_candidate_metrics  (cost=0.56..3.57 rows=1 width=14) (actual time=0.001..0.001 rows=1 loops=10000)
               Index Cond: (ml_candidate_metrics.id = "ANY_subquery".id)
               Buffers: shared hit=50000
               I/O Timings: read=0.000 write=0.000
Planning Time: 2.399 ms
Execution Time: 33.052 ms
DeleteExperimentRunsService metric batch, after (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207191

 Delete on public.ml_candidate_metrics  (cost=3129.50..12314.88 rows=0 width=0) (actual time=442.011..442.014 rows=0 loops=1)
   Buffers: shared hit=62393 read=679 dirtied=2940
   WAL: records=10000 fpi=2938 bytes=24502614
   I/O Timings: read=364.831 write=0.000
   ->  Nested Loop  (cost=3129.50..12314.88 rows=2567 width=38) (actual time=20.946..410.284 rows=10000 loops=1)
         Buffers: shared hit=49457 read=679
         I/O Timings: read=364.831 write=0.000
         ->  HashAggregate  (cost=3128.93..3154.60 rows=2567 width=40) (actual time=18.066..20.895 rows=10000 loops=1)
               Group Key: "ANY_subquery".id
               Batches: 1  Memory Usage: 1425kB
               Buffers: shared hit=32 read=104
               I/O Timings: read=10.776 write=0.000
               ->  Subquery Scan on "ANY_subquery"  (cost=0.99..3122.51 rows=2567 width=40) (actual time=4.894..15.419 rows=10000 loops=1)
                     Buffers: shared hit=32 read=104
                     I/O Timings: read=10.776 write=0.000
                     ->  Limit  (cost=0.99..3096.84 rows=2567 width=8) (actual time=4.881..13.895 rows=10000 loops=1)
                           Buffers: shared hit=32 read=104
                           I/O Timings: read=10.776 write=0.000
                           ->  Nested Loop  (cost=0.99..3096.84 rows=2567 width=8) (actual time=4.880..13.130 rows=10000 loops=1)
                                 Buffers: shared hit=32 read=104
                                 I/O Timings: read=10.776 write=0.000
                                 ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..56.00 rows=61 width=8) (actual time=2.542..2.651 rows=3 loops=1)
                                       Index Cond: ((ml_candidates.experiment_id = <experiment_a_id>) AND (ml_candidates.eid >= '<first eid of the batch>'::uuid))
                                       Buffers: shared hit=3 read=6
                                       I/O Timings: read=2.584 write=0.000
                                 ->  Index Only Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics ml_candidate_metrics_1  (cost=0.56..40.24 rows=961 width=16) (actual time=2.374..3.191 rows=3333 loops=3)
                                       Index Cond: (ml_candidate_metrics_1.candidate_id = ml_candidates.id)
                                       Heap Fetches: 52
                                       Buffers: shared hit=29 read=98
                                       I/O Timings: read=8.192 write=0.000
         ->  Index Scan using ml_candidate_metrics_pkey on public.ml_candidate_metrics  (cost=0.56..3.57 rows=1 width=14) (actual time=0.039..0.039 rows=1 loops=10000)
               Index Cond: (ml_candidate_metrics.id = "ANY_subquery".id)
               Buffers: shared hit=49425 read=575
               I/O Timings: read=354.055 write=0.000
Planning Time: 9.04 ms
Execution Time: 442.316 ms
DeleteExperimentRunsService metric batch, after (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207192

 Delete on public.ml_candidate_metrics  (cost=3129.50..12314.88 rows=0 width=0) (actual time=51.820..51.823 rows=0 loops=1)
   Buffers: shared hit=69222
   WAL: records=10000 fpi=0 bytes=540000
   I/O Timings: read=0.000 write=0.000
   ->  Nested Loop  (cost=3129.50..12314.88 rows=2567 width=38) (actual time=22.176..46.624 rows=10000 loops=1)
         Buffers: shared hit=59222
         I/O Timings: read=0.000 write=0.000
         ->  HashAggregate  (cost=3128.93..3154.60 rows=2567 width=40) (actual time=22.161..23.957 rows=10000 loops=1)
               Group Key: "ANY_subquery".id
               Batches: 1  Memory Usage: 1425kB
               Buffers: shared hit=9222
               I/O Timings: read=0.000 write=0.000
               ->  Subquery Scan on "ANY_subquery"  (cost=0.99..3122.51 rows=2567 width=40) (actual time=0.088..19.340 rows=10000 loops=1)
                     Buffers: shared hit=9222
                     I/O Timings: read=0.000 write=0.000
                     ->  Limit  (cost=0.99..3096.84 rows=2567 width=8) (actual time=0.080..17.712 rows=10000 loops=1)
                           Buffers: shared hit=9222
                           I/O Timings: read=0.000 write=0.000
                           ->  Nested Loop  (cost=0.99..3096.84 rows=2567 width=8) (actual time=0.079..16.928 rows=10000 loops=1)
                                 Buffers: shared hit=9222
                                 I/O Timings: read=0.000 write=0.000
                                 ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..56.00 rows=61 width=8) (actual time=0.026..0.033 rows=3 loops=1)
                                       Index Cond: ((ml_candidates.experiment_id = <experiment_a_id>) AND (ml_candidates.eid >= '<first eid of the batch>'::uuid))
                                       Buffers: shared hit=9
                                       I/O Timings: read=0.000 write=0.000
                                 ->  Index Only Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics ml_candidate_metrics_1  (cost=0.56..40.24 rows=961 width=16) (actual time=0.027..5.324 rows=3333 loops=3)
                                       Index Cond: (ml_candidate_metrics_1.candidate_id = ml_candidates.id)
                                       Heap Fetches: 10000
                                       Buffers: shared hit=9213
                                       I/O Timings: read=0.000 write=0.000
         ->  Index Scan using ml_candidate_metrics_pkey on public.ml_candidate_metrics  (cost=0.56..3.57 rows=1 width=14) (actual time=0.002..0.002 rows=1 loops=10000)
               Index Cond: (ml_candidate_metrics.id = "ANY_subquery".id)
               Buffers: shared hit=50000
               I/O Timings: read=0.000 write=0.000
Planning Time: 1.808 ms
Execution Time: 52.098 ms
Foreign key cascade delete of the run with the most metric rows, before (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207088

 Delete on public.ml_candidate_metrics  (cost=0.44..56596.46 rows=0 width=0) (actual time=1506.248..1506.249 rows=0 loops=1)
   Buffers: shared hit=638320 dirtied=11746
   WAL: records=614560 fpi=11746 bytes=128849174
   I/O Timings: read=0.000 write=0.000
   ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..56596.46 rows=623886 width=6) (actual time=0.060..107.066 rows=614560 loops=1)
         Index Cond: (ml_candidate_metrics.candidate_id = <run_id>)
         Buffers: shared hit=12428
         I/O Timings: read=0.000 write=0.000
Planning Time: 0.596 ms
Execution Time: 1506.364 ms
Foreign key cascade delete of the run with the most metric rows, before (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207089

 Delete on public.ml_candidate_metrics  (cost=0.44..56596.46 rows=0 width=0) (actual time=366.622..366.623 rows=0 loops=1)
   Buffers: shared hit=626988
   WAL: records=614560 fpi=0 bytes=33186240
   I/O Timings: read=0.000 write=0.000
   ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..56596.46 rows=623886 width=6) (actual time=0.078..135.855 rows=614560 loops=1)
         Index Cond: (ml_candidate_metrics.candidate_id = <run_id>)
         Buffers: shared hit=12428
         I/O Timings: read=0.000 write=0.000
Planning Time: 0.576 ms
Execution Time: 366.724 ms
Foreign key cascade delete of the run with the most metric rows, after (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207193

 Delete on public.ml_candidate_metrics  (cost=0.44..55374.97 rows=0 width=0) (actual time=1153.937..1153.938 rows=0 loops=1)
   Buffers: shared hit=638320 dirtied=11746
   WAL: records=614560 fpi=11746 bytes=128849174
   I/O Timings: read=0.000 write=0.000
   ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..55374.97 rows=615858 width=6) (actual time=0.066..123.704 rows=614560 loops=1)
         Index Cond: (ml_candidate_metrics.candidate_id = <run_id>)
         Buffers: shared hit=12428
         I/O Timings: read=0.000 write=0.000
Planning Time: 0.599 ms
Execution Time: 1154.024 ms
Foreign key cascade delete of the run with the most metric rows, after (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207194

 Delete on public.ml_candidate_metrics  (cost=0.44..55374.97 rows=0 width=0) (actual time=486.586..486.587 rows=0 loops=1)
   Buffers: shared hit=626988
   WAL: records=614560 fpi=0 bytes=33186240
   I/O Timings: read=0.000 write=0.000
   ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics  (cost=0.44..55374.97 rows=615858 width=6) (actual time=0.081..145.405 rows=614560 loops=1)
         Index Cond: (ml_candidate_metrics.candidate_id = <run_id>)
         Buffers: shared hit=12428
         I/O Timings: read=0.000 write=0.000
Planning Time: 0.69 ms
Execution Time: 486.675 ms
Insert of 1,000 metrics, before (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207090

 Insert on public.ml_candidate_metrics  (cost=0.00..35.00 rows=0 width=0) (actual time=56.125..56.125 rows=0 loops=1)
   Buffers: shared hit=19452 read=56 dirtied=50 written=14
   WAL: records=5048 fpi=7 bytes=417610
   I/O Timings: read=39.886 write=0.372
   ->  Function Scan on pg_catalog.generate_series g  (cost=0.00..35.00 rows=1000 width=124) (actual time=2.263..3.492 rows=1000 loops=1)
         Function Call: generate_series(1, 1000)
         Buffers: shared hit=1009 read=5 dirtied=1
         WAL: records=31 fpi=0 bytes=3069
         I/O Timings: read=2.062 write=0.000
Trigger RI_ConstraintTrigger_c_39919 for constraint fk_e2684c8ffc: time=77.948 calls=1000
Trigger RI_ConstraintTrigger_c_40793 for constraint fk_ml_candidate_metrics_on_candidate_id: time=6.500 calls=1000
Trigger trigger_979e7f45114f: time=11.192 calls=1000
Planning Time: 0.167 ms
Execution Time: 140.798 ms
Insert of 1,000 metrics, before (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207091

 Insert on public.ml_candidate_metrics  (cost=0.00..35.00 rows=0 width=0) (actual time=23.395..23.395 rows=0 loops=1)
   Buffers: shared hit=19453 read=2 dirtied=20 written=18
   WAL: records=5060 fpi=2 bytes=395664
   I/O Timings: read=4.124 write=3.948
   ->  Function Scan on pg_catalog.generate_series g  (cost=0.00..35.00 rows=1000 width=124) (actual time=0.140..1.340 rows=1000 loops=1)
         Function Call: generate_series(1, 1000)
         Buffers: shared hit=1014
         WAL: records=30 fpi=0 bytes=2970
         I/O Timings: read=0.000 write=0.000
Trigger RI_ConstraintTrigger_c_39919 for constraint fk_e2684c8ffc: time=8.828 calls=1000
Trigger RI_ConstraintTrigger_c_40793 for constraint fk_ml_candidate_metrics_on_candidate_id: time=5.185 calls=1000
Trigger trigger_979e7f45114f: time=6.023 calls=1000
Planning Time: 0.186 ms
Execution Time: 37.613 ms
Insert of 1,000 metrics, after (first run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207195

 Insert on public.ml_candidate_metrics  (cost=0.00..35.00 rows=0 width=0) (actual time=51.513..51.513 rows=0 loops=1)
   Buffers: shared hit=23501 read=58 dirtied=64 written=25
   WAL: records=6059 fpi=38 bytes=768041
   I/O Timings: read=26.344 write=1.877
   ->  Function Scan on pg_catalog.generate_series g  (cost=0.00..35.00 rows=1000 width=124) (actual time=0.397..1.807 rows=1000 loops=1)
         Function Call: generate_series(1, 1000)
         Buffers: shared hit=1009 read=5 dirtied=1
         WAL: records=31 fpi=0 bytes=3069
         I/O Timings: read=0.180 write=0.000
Trigger RI_ConstraintTrigger_c_39919 for constraint fk_e2684c8ffc: time=62.062 calls=1000
Trigger RI_ConstraintTrigger_c_40793 for constraint fk_ml_candidate_metrics_on_candidate_id: time=5.928 calls=1000
Trigger trigger_979e7f45114f: time=9.957 calls=1000
Planning Time: 0.123 ms
Execution Time: 119.703 ms
Insert of 1,000 metrics, after (second run)

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207196

 Insert on public.ml_candidate_metrics  (cost=0.00..35.00 rows=0 width=0) (actual time=28.833..28.834 rows=0 loops=1)
   Buffers: shared hit=23486 read=2 dirtied=22 written=20
   WAL: records=6062 fpi=2 bytes=491440
   I/O Timings: read=0.940 write=2.039
   ->  Function Scan on pg_catalog.generate_series g  (cost=0.00..35.00 rows=1000 width=124) (actual time=0.164..1.636 rows=1000 loops=1)
         Function Call: generate_series(1, 1000)
         Buffers: shared hit=1014
         WAL: records=30 fpi=0 bytes=2970
         I/O Timings: read=0.000 write=0.000
Trigger RI_ConstraintTrigger_c_39919 for constraint fk_e2684c8ffc: time=11.502 calls=1000
Trigger RI_ConstraintTrigger_c_40793 for constraint fk_ml_candidate_metrics_on_candidate_id: time=6.945 calls=1000
Trigger trigger_979e7f45114f: time=7.639 calls=1000
Planning Time: 0.142 ms
Execution Time: 47.516 ms
Consecutive metric batches, batch 1, before

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207092

 Delete on public.ml_candidate_metrics  (cost=4204.77..13393.75 rows=0 width=0) (actual time=33.377..33.381 rows=0 loops=1)
   Buffers: shared hit=60484
   WAL: records=10000 fpi=0 bytes=540000
   I/O Timings: read=0.000 write=0.000
   ->  Nested Loop  (cost=4204.77..13393.75 rows=2568 width=38) (actual time=9.107..28.868 rows=10000 loops=1)
         Buffers: shared hit=50484
         I/O Timings: read=0.000 write=0.000
         ->  HashAggregate  (cost=4204.21..4229.89 rows=2568 width=40) (actual time=9.092..10.894 rows=10000 loops=1)
               Group Key: "ANY_subquery".id
               Batches: 1  Memory Usage: 1425kB
               Buffers: shared hit=484
               I/O Timings: read=0.000 write=0.000
               ->  Subquery Scan on "ANY_subquery"  (cost=0.87..4197.79 rows=2568 width=40) (actual time=0.098..6.549 rows=10000 loops=1)
                     Buffers: shared hit=484
                     I/O Timings: read=0.000 write=0.000
                     ->  Limit  (cost=0.87..4172.11 rows=2568 width=8) (actual time=0.088..5.025 rows=10000 loops=1)
                           Buffers: shared hit=484
                           I/O Timings: read=0.000 write=0.000
                           ->  Nested Loop  (cost=0.87..4172.11 rows=2568 width=8) (actual time=0.088..4.222 rows=10000 loops=1)
                                 Buffers: shared hit=484
                                 I/O Timings: read=0.000 write=0.000
                                 ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..56.00 rows=61 width=8) (actual time=0.039..0.056 rows=3 loops=1)
                                       Index Cond: ((ml_candidates.experiment_id = <experiment_a_id>) AND (ml_candidates.eid >= '<first eid of the batch>'::uuid))
                                       Buffers: shared hit=9
                                       I/O Timings: read=0.000 write=0.000
                                 ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics ml_candidate_metrics_1  (cost=0.44..57.88 rows=960 width=16) (actual time=0.030..1.047 rows=3333 loops=3)
                                       Index Cond: (ml_candidate_metrics_1.candidate_id = ml_candidates.id)
                                       Buffers: shared hit=475
                                       I/O Timings: read=0.000 write=0.000
         ->  Index Scan using ml_candidate_metrics_pkey on public.ml_candidate_metrics  (cost=0.56..3.57 rows=1 width=14) (actual time=0.002..0.002 rows=1 loops=10000)
               Index Cond: (ml_candidate_metrics.id = "ANY_subquery".id)
               Buffers: shared hit=50000
               I/O Timings: read=0.000 write=0.000
Planning Time: 2.046 ms
Execution Time: 33.646 ms
Consecutive metric batches, batch 2, before

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207094

 Delete on public.ml_candidate_metrics  (cost=4204.77..13393.75 rows=0 width=0) (actual time=64.763..64.766 rows=0 loops=1)
   Buffers: shared hit=61163 read=43 dirtied=361
   WAL: records=10468 fpi=361 bytes=3511273
   I/O Timings: read=24.731 write=0.000
   ->  Nested Loop  (cost=4204.77..13393.75 rows=2568 width=38) (actual time=13.759..58.428 rows=10000 loops=1)
         Buffers: shared hit=50814 read=43 dirtied=12
         WAL: records=468 fpi=12 bytes=124572
         I/O Timings: read=24.731 write=0.000
         ->  HashAggregate  (cost=4204.21..4229.89 rows=2568 width=40) (actual time=13.737..15.803 rows=10000 loops=1)
               Group Key: "ANY_subquery".id
               Batches: 1  Memory Usage: 1425kB
               Buffers: shared hit=857 dirtied=12
               WAL: records=468 fpi=12 bytes=124572
               I/O Timings: read=0.000 write=0.000
               ->  Subquery Scan on "ANY_subquery"  (cost=0.87..4197.79 rows=2568 width=40) (actual time=4.883..10.767 rows=10000 loops=1)
                     Buffers: shared hit=857 dirtied=12
                     WAL: records=468 fpi=12 bytes=124572
                     I/O Timings: read=0.000 write=0.000
                     ->  Limit  (cost=0.87..4172.11 rows=2568 width=8) (actual time=4.859..9.059 rows=10000 loops=1)
                           Buffers: shared hit=857 dirtied=12
                           WAL: records=468 fpi=12 bytes=124572
                           I/O Timings: read=0.000 write=0.000
                           ->  Nested Loop  (cost=0.87..4172.11 rows=2568 width=8) (actual time=4.857..8.139 rows=10000 loops=1)
                                 Buffers: shared hit=857 dirtied=12
                                 WAL: records=468 fpi=12 bytes=124572
                                 I/O Timings: read=0.000 write=0.000
                                 ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..56.00 rows=61 width=8) (actual time=0.044..0.060 rows=3 loops=1)
                                       Index Cond: ((ml_candidates.experiment_id = <experiment_a_id>) AND (ml_candidates.eid >= '<first eid of the batch>'::uuid))
                                       Buffers: shared hit=9
                                       I/O Timings: read=0.000 write=0.000
                                 ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics ml_candidate_metrics_1  (cost=0.44..57.88 rows=960 width=16) (actual time=1.598..2.313 rows=3333 loops=3)
                                       Index Cond: (ml_candidate_metrics_1.candidate_id = ml_candidates.id)
                                       Buffers: shared hit=848 dirtied=12
                                       WAL: records=468 fpi=12 bytes=124572
                                       I/O Timings: read=0.000 write=0.000
         ->  Index Scan using ml_candidate_metrics_pkey on public.ml_candidate_metrics  (cost=0.56..3.57 rows=1 width=14) (actual time=0.004..0.004 rows=1 loops=10000)
               Index Cond: (ml_candidate_metrics.id = "ANY_subquery".id)
               Buffers: shared hit=49957 read=43
               I/O Timings: read=24.731 write=0.000
Planning Time: 2.355 ms
Execution Time: 65.043 ms
Consecutive metric batches, batch 3, before

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207096

 Delete on public.ml_candidate_metrics  (cost=4204.77..13393.75 rows=0 width=0) (actual time=54.530..54.534 rows=0 loops=1)
   Buffers: shared hit=60946 read=28 dirtied=291
   WAL: records=10361 fpi=291 bytes=2934413
   I/O Timings: read=16.348 write=0.000
   ->  Nested Loop  (cost=4204.77..13393.75 rows=2568 width=38) (actual time=13.617..48.524 rows=10000 loops=1)
         Buffers: shared hit=50667 read=28 dirtied=12
         WAL: records=361 fpi=12 bytes=118058
         I/O Timings: read=16.348 write=0.000
         ->  HashAggregate  (cost=4204.21..4229.89 rows=2568 width=40) (actual time=12.951..14.789 rows=10000 loops=1)
               Group Key: "ANY_subquery".id
               Batches: 1  Memory Usage: 1425kB
               Buffers: shared hit=695 dirtied=12
               WAL: records=361 fpi=12 bytes=118058
               I/O Timings: read=0.000 write=0.000
               ->  Subquery Scan on "ANY_subquery"  (cost=0.87..4197.79 rows=2568 width=40) (actual time=3.580..9.874 rows=10000 loops=1)
                     Buffers: shared hit=695 dirtied=12
                     WAL: records=361 fpi=12 bytes=118058
                     I/O Timings: read=0.000 write=0.000
                     ->  Limit  (cost=0.87..4172.11 rows=2568 width=8) (actual time=3.566..8.063 rows=10000 loops=1)
                           Buffers: shared hit=695 dirtied=12
                           WAL: records=361 fpi=12 bytes=118058
                           I/O Timings: read=0.000 write=0.000
                           ->  Nested Loop  (cost=0.87..4172.11 rows=2568 width=8) (actual time=3.565..7.139 rows=10000 loops=1)
                                 Buffers: shared hit=695 dirtied=12
                                 WAL: records=361 fpi=12 bytes=118058
                                 I/O Timings: read=0.000 write=0.000
                                 ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..56.00 rows=61 width=8) (actual time=0.036..0.051 rows=3 loops=1)
                                       Index Cond: ((ml_candidates.experiment_id = <experiment_a_id>) AND (ml_candidates.eid >= '<first eid of the batch>'::uuid))
                                       Buffers: shared hit=9
                                       I/O Timings: read=0.000 write=0.000
                                 ->  Index Scan using index_ml_candidate_metrics_on_candidate_id on public.ml_candidate_metrics ml_candidate_metrics_1  (cost=0.44..57.88 rows=960 width=16) (actual time=1.170..1.956 rows=3333 loops=3)
                                       Index Cond: (ml_candidate_metrics_1.candidate_id = ml_candidates.id)
                                       Buffers: shared hit=686 dirtied=12
                                       WAL: records=361 fpi=12 bytes=118058
                                       I/O Timings: read=0.000 write=0.000
         ->  Index Scan using ml_candidate_metrics_pkey on public.ml_candidate_metrics  (cost=0.56..3.57 rows=1 width=14) (actual time=0.003..0.003 rows=1 loops=10000)
               Index Cond: (ml_candidate_metrics.id = "ANY_subquery".id)
               Buffers: shared hit=49972 read=28
               I/O Timings: read=16.348 write=0.000
Planning Time: 2.063 ms
Execution Time: 54.843 ms
Consecutive metric batches, batch 1, after

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207197

 Delete on public.ml_candidate_metrics  (cost=3130.16..12315.54 rows=0 width=0) (actual time=48.943..48.946 rows=0 loops=1)
   Buffers: shared hit=69222
   WAL: records=10000 fpi=0 bytes=540000
   I/O Timings: read=0.000 write=0.000
   ->  Nested Loop  (cost=3130.16..12315.54 rows=2567 width=38) (actual time=21.332..44.058 rows=10000 loops=1)
         Buffers: shared hit=59222
         I/O Timings: read=0.000 write=0.000
         ->  HashAggregate  (cost=3129.60..3155.27 rows=2567 width=40) (actual time=21.319..23.035 rows=10000 loops=1)
               Group Key: "ANY_subquery".id
               Batches: 1  Memory Usage: 1425kB
               Buffers: shared hit=9222
               I/O Timings: read=0.000 write=0.000
               ->  Subquery Scan on "ANY_subquery"  (cost=0.99..3123.18 rows=2567 width=40) (actual time=0.083..18.676 rows=10000 loops=1)
                     Buffers: shared hit=9222
                     I/O Timings: read=0.000 write=0.000
                     ->  Limit  (cost=0.99..3097.51 rows=2567 width=8) (actual time=0.076..17.161 rows=10000 loops=1)
                           Buffers: shared hit=9222
                           I/O Timings: read=0.000 write=0.000
                           ->  Nested Loop  (cost=0.99..3097.51 rows=2567 width=8) (actual time=0.076..16.393 rows=10000 loops=1)
                                 Buffers: shared hit=9222
                                 I/O Timings: read=0.000 write=0.000
                                 ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..56.00 rows=61 width=8) (actual time=0.027..0.034 rows=3 loops=1)
                                       Index Cond: ((ml_candidates.experiment_id = <experiment_a_id>) AND (ml_candidates.eid >= '<first eid of the batch>'::uuid))
                                       Buffers: shared hit=9
                                       I/O Timings: read=0.000 write=0.000
                                 ->  Index Only Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics ml_candidate_metrics_1  (cost=0.56..40.25 rows=961 width=16) (actual time=0.023..5.151 rows=3333 loops=3)
                                       Index Cond: (ml_candidate_metrics_1.candidate_id = ml_candidates.id)
                                       Heap Fetches: 10000
                                       Buffers: shared hit=9213
                                       I/O Timings: read=0.000 write=0.000
         ->  Index Scan using ml_candidate_metrics_pkey on public.ml_candidate_metrics  (cost=0.56..3.57 rows=1 width=14) (actual time=0.002..0.002 rows=1 loops=10000)
               Index Cond: (ml_candidate_metrics.id = "ANY_subquery".id)
               Buffers: shared hit=50000
               I/O Timings: read=0.000 write=0.000
Planning Time: 1.826 ms
Execution Time: 49.197 ms
Consecutive metric batches, batch 2, after

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207199

 Delete on public.ml_candidate_metrics  (cost=3130.16..12315.54 rows=0 width=0) (actual time=133.586..133.590 rows=0 loops=1)
   Buffers: shared hit=76729 read=205 dirtied=1448
   WAL: records=13027 fpi=1448 bytes=12468144
   I/O Timings: read=65.468 write=0.000
   ->  Nested Loop  (cost=3130.16..12315.54 rows=2567 width=38) (actual time=32.178..121.248 rows=10000 loops=1)
         Buffers: shared hit=65370 read=205 dirtied=89
         WAL: records=3027 fpi=89 bytes=840293
         I/O Timings: read=65.468 write=0.000
         ->  HashAggregate  (cost=3129.60..3155.27 rows=2567 width=40) (actual time=32.153..34.244 rows=10000 loops=1)
               Group Key: "ANY_subquery".id
               Batches: 1  Memory Usage: 1425kB
               Buffers: shared hit=15488 read=87 dirtied=89
               WAL: records=3027 fpi=89 bytes=840293
               I/O Timings: read=4.958 write=0.000
               ->  Subquery Scan on "ANY_subquery"  (cost=0.99..3123.18 rows=2567 width=40) (actual time=16.483..29.301 rows=10000 loops=1)
                     Buffers: shared hit=15488 read=87 dirtied=89
                     WAL: records=3027 fpi=89 bytes=840293
                     I/O Timings: read=4.958 write=0.000
                     ->  Limit  (cost=0.99..3097.51 rows=2567 width=8) (actual time=16.468..27.678 rows=10000 loops=1)
                           Buffers: shared hit=15488 read=87 dirtied=89
                           WAL: records=3027 fpi=89 bytes=840293
                           I/O Timings: read=4.958 write=0.000
                           ->  Nested Loop  (cost=0.99..3097.51 rows=2567 width=8) (actual time=16.467..26.879 rows=10000 loops=1)
                                 Buffers: shared hit=15488 read=87 dirtied=89
                                 WAL: records=3027 fpi=89 bytes=840293
                                 I/O Timings: read=4.958 write=0.000
                                 ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..56.00 rows=61 width=8) (actual time=0.026..0.034 rows=3 loops=1)
                                       Index Cond: ((ml_candidates.experiment_id = <experiment_a_id>) AND (ml_candidates.eid >= '<first eid of the batch>'::uuid))
                                       Buffers: shared hit=9
                                       I/O Timings: read=0.000 write=0.000
                                 ->  Index Only Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics ml_candidate_metrics_1  (cost=0.56..40.25 rows=961 width=16) (actual time=5.477..8.633 rows=3333 loops=3)
                                       Index Cond: (ml_candidate_metrics_1.candidate_id = ml_candidates.id)
                                       Heap Fetches: 16781
                                       Buffers: shared hit=15479 read=87 dirtied=89
                                       WAL: records=3027 fpi=89 bytes=840293
                                       I/O Timings: read=4.958 write=0.000
         ->  Index Scan using ml_candidate_metrics_pkey on public.ml_candidate_metrics  (cost=0.56..3.57 rows=1 width=14) (actual time=0.008..0.008 rows=1 loops=10000)
               Index Cond: (ml_candidate_metrics.id = "ANY_subquery".id)
               Buffers: shared hit=49882 read=118
               I/O Timings: read=60.509 write=0.000
Planning Time: 1.825 ms
Execution Time: 133.854 ms
Consecutive metric batches, batch 3, after

Plan: https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/100333/commands/207201

 Delete on public.ml_candidate_metrics  (cost=3130.16..12315.54 rows=0 width=0) (actual time=62.519..62.522 rows=0 loops=1)
   Buffers: shared hit=79068 read=82 dirtied=121
   WAL: records=13933 fpi=121 bytes=1692555
   I/O Timings: read=1.101 write=0.000
   ->  Nested Loop  (cost=3130.16..12315.54 rows=2567 width=38) (actual time=33.250..57.177 rows=10000 loops=1)
         Buffers: shared hit=69034 read=82 dirtied=87
         WAL: records=3933 fpi=87 bytes=875529
         I/O Timings: read=1.101 write=0.000
         ->  HashAggregate  (cost=3129.60..3155.27 rows=2567 width=40) (actual time=33.232..34.935 rows=10000 loops=1)
               Group Key: "ANY_subquery".id
               Batches: 1  Memory Usage: 1425kB
               Buffers: shared hit=19034 read=82 dirtied=87
               WAL: records=3933 fpi=87 bytes=875529
               I/O Timings: read=1.101 write=0.000
               ->  Subquery Scan on "ANY_subquery"  (cost=0.99..3123.18 rows=2567 width=40) (actual time=20.685..30.646 rows=10000 loops=1)
                     Buffers: shared hit=19034 read=82 dirtied=87
                     WAL: records=3933 fpi=87 bytes=875529
                     I/O Timings: read=1.101 write=0.000
                     ->  Limit  (cost=0.99..3097.51 rows=2567 width=8) (actual time=20.670..29.163 rows=10000 loops=1)
                           Buffers: shared hit=19034 read=82 dirtied=87
                           WAL: records=3933 fpi=87 bytes=875529
                           I/O Timings: read=1.101 write=0.000
                           ->  Nested Loop  (cost=0.99..3097.51 rows=2567 width=8) (actual time=20.668..28.397 rows=10000 loops=1)
                                 Buffers: shared hit=19034 read=82 dirtied=87
                                 WAL: records=3933 fpi=87 bytes=875529
                                 I/O Timings: read=1.101 write=0.000
                                 ->  Index Scan using index_ml_candidates_on_experiment_id_and_eid on public.ml_candidates  (cost=0.43..56.00 rows=61 width=8) (actual time=0.028..0.035 rows=3 loops=1)
                                       Index Cond: ((ml_candidates.experiment_id = <experiment_a_id>) AND (ml_candidates.eid >= '<first eid of the batch>'::uuid))
                                       Buffers: shared hit=9
                                       I/O Timings: read=0.000 write=0.000
                                 ->  Index Only Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics ml_candidate_metrics_1  (cost=0.56..40.25 rows=961 width=16) (actual time=6.877..9.157 rows=3333 loops=3)
                                       Index Cond: (ml_candidate_metrics_1.candidate_id = ml_candidates.id)
                                       Heap Fetches: 19961
                                       Buffers: shared hit=19025 read=82 dirtied=87
                                       WAL: records=3933 fpi=87 bytes=875529
                                       I/O Timings: read=1.101 write=0.000
         ->  Index Scan using ml_candidate_metrics_pkey on public.ml_candidate_metrics  (cost=0.56..3.57 rows=1 width=14) (actual time=0.002..0.002 rows=1 loops=10000)
               Index Cond: (ml_candidate_metrics.id = "ANY_subquery".id)
               Buffers: shared hit=50000
               I/O Timings: read=0.000 write=0.000
Planning Time: 1.824 ms
Execution Time: 62.775 ms

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.

Edited by Eduardo Bonet

Merge request reports

Loading
Loading