Add GraphQL fields to page through the metrics of an ML run

What does this MR do and why?

Adds GraphQL fields that load the metrics of one ML run page by page: every metric name with its newest value (50 names per page), the newest values of each metric on that page, and the values of one metric by name. The run page embeds only the 1,000 newest metric rows today, so on large runs the metrics logged earlier are missing from it. The fields stay behind the ml_candidate_metrics_pagination feature flag, and a follow-up MR switches the page to them behind the same flag.

Each query reads a bounded number of rows from the (candidate_id, name, id DESC) index that !272094 (merged) adds. The flag stays off until that index is deployed to GitLab.com, so this MR can merge before it.

Design notes

New schema items, all marked as experiments (no changelog entry, no consumer until the frontend MR):

  • Query.mlCandidate(id:) (app/graphql/resolvers/ml/candidate_detail_resolver.rb): the run page has no GraphQL path to one run today (mlExperiment.candidates has no filter). It authorizes like Query.mlExperiment and the run page: read_model_experiments on the project, null when the experiment is marked for deletion. Limited to one call per query. It returns null while the flag is disabled for the run's project.
  • MlCandidate.latestMetrics (app/graphql/resolvers/ml/candidate_latest_metrics_resolver.rb, Ml::CandidateMetric.latest_by_name): a loose index scan (LooseIndexScan) reads the next 51 names after the cursor, then a LATERAL ... ORDER BY id DESC LIMIT 1 reads the newest row of each name. The page is externally paginated (ForwardOnlyExternallyPaginatedArrayExtension, like Repository.tags) with the Base64 of the last name as the cursor. The keyset connection would add name > cursor outside the recursive CTE, which then walks every name before the cursor. The field uses the plain FieldCallCount limit of one call per query, so the one-run rule holds whatever the state of limit_ml_candidate_graphql_fields. It returns an empty page while the flag is disabled for the run's project, because MlCandidate is also reachable through mlExperiment.candidates and mlModel. Without the index, its loose index scan would sort every row of the run at each step.
  • MlCandidateLatestMetric.history(first:) (app/graphql/types/ml/candidate_latest_metric_type.rb, Ml::CandidateMetric.recent_for_names): a BatchLoader runs one query for the page: unnest(names) with a LATERAL ... ORDER BY id DESC LIMIT first per name. Aliases of history with different first values share that query: it uses the largest first, and each alias takes its first values. A page reads at most 50 x 100 rows. The type is reachable only through latestMetrics, so the history can't fan out over many runs.
  • MlCandidate.metrics(name:) (app/graphql/resolvers/ml/candidate_metrics_resolver.rb): the existing keyset connection (newest first), filtered on the name, so later pages of one metric use (candidate_id, name, id) as the index condition. The name: filter returns no values while the flag is disabled for the run's project.
  • MlCandidateLatestMetric declares its own granular token directive (read_ml_flow_run on the project, like MlCandidate), so Ml::CandidateMetric gets belongs_to :project and the page preloads it.

The loose index scan relies on the recursive CTE emitting names in ascending order for its LIMIT, like the other LooseIndexScan callers (EachBatch#distinct_each_batch, Ci::BuildSourceFinder).

Feature flag: ml_candidate_metrics_pagination (gitlab_com_derisk, default off), rollout issue https://gitlab.com/gitlab-org/gitlab/-/work_items/640966. The actor is the run's project. Query.mlCandidate has no project until it loads the run, so the resolver checks the flag after loading it, next to the existing permission check. The flag-disabled result follows the GraphQL style guide's pattern for a toggled field value: null for mlCandidate, and an empty page for the non-nullable latestMetrics connection. Both field descriptions name the flag. The frontend MR reuses the flag for the run page. Rollback: disable the flag.

metrics(name:) checks the flag too. Without the index, PostgreSQL reads a name-filtered page by scanning ml_candidate_metrics_pkey backward. The first page of one name of run 2219689 took 2.1 to 2.5 minutes on Database Lab (section 4 of the query plans). The unfiltered metrics connection does not change.

Related MRs:

  • The (candidate_id, name, id DESC) index: !272094 (merged) (#635116 (closed)). It merges after !270985 (merged) merges. The metric order cap MR !272170 (closed) is closed and does not ship. The ml_candidate_metrics_pagination flag stays off until the index is deployed.
  • The frontend MR stacked on this one: !272230 (merged).
  • !269544 removes limit_ml_candidate_graphql_fields and edits the same block of app/graphql/types/ml/candidate_type.rb. The new field already uses FieldCallCount, so whichever merges second only rebases.

References

Screenshots or screen recordings

No UI change.

How to set up and validate locally

  1. Log metrics to a run in GDK and enable the flag, for example in the Rails console:

    c = Ml::Candidate.last
    Feature.enable(:ml_candidate_metrics_pagination, c.project)
    %w[loss accuracy f1].each { |n| 3.times { |s| Ml::CandidateMetric.create!(candidate: c, name: n, step: s, value: s) } }
    c.to_global_id.to_s
  2. Open http://gdk.test:3000/-/graphql-explorer as a user who can see the project.

  3. Run this query with the ID from step 1:

    { mlCandidate(id: "gid://gitlab/Ml::Candidate/<id>") {
        latestMetrics(first: 2) {
          nodes { name step value history(first: 2) { step value } }
          pageInfo { hasNextPage endCursor }
        }
    } }

    Expect: accuracy and f1 with step 2, each with the values of steps 2 and 1, and hasNextPage: true.

  4. Run it again with latestMetrics(first: 2, after: "<endCursor>").

    Expect: only loss, and hasNextPage: false.

  5. Run { mlCandidate(id: "...") { metrics(name: "loss", first: 2) { nodes { step } pageInfo { endCursor } } } }.

    Expect: steps 2 and 1. Passing the endCursor as after returns step 0.

  6. Run Feature.disable(:ml_candidate_metrics_pagination, c.project) in the console and repeat step 3.

    Expect: mlCandidate is null.

Database review

ml_candidate_metrics on GitLab.com: 50.4 M rows, 5.9 GB heap. The (candidate_id, name, id DESC) index from #635116 (closed) is 3.0 GB. The plans ran on Database Lab after CREATE INDEX index_ml_candidate_metrics_on_candidate_id_name_id_desc ON ml_candidate_metrics USING btree (candidate_id, name, id DESC) and ANALYZE.

Runs used:

  • Run 2219689: the run with the most rows (614,560 rows, 25 names).
  • Run 4309014: the run with the most names (2,641 names, 441,038 rows).
  • Run 4305254: 1,458 names, one row each, not read before on the clone.

"First run" is the first execution on the clone and "second run" repeats it. An earlier aggregate on the clone had read the index pages of run 4309014, so its first page shows few reads. Runs 4305254 and 2219689 show the cold reads.

The Database Lab CLI rejects SQL longer than about 930 bytes. The plans ran on the Rails SQL with the double quotes removed. The deep page also renames the CTE and drops redundant ml_candidate_metrics. prefixes. The history plans read the names from a 50-row scratch table (unnest(ARRAY(SELECT name FROM z640899 ...))) instead of a literal array, and use LIMIT 101 where the application uses at most 100. Section 2 also has plans of the shipped SQL, and section 4 ran on a clone without the new index. Metric names in the plans are replaced with <name>.

Query plans

1. latestMetrics: names page with the newest value of each name

SELECT "ml_candidate_metrics".* FROM (WITH RECURSIVE "loose_index_scan_cte" AS ((SELECT "ml_candidate_metrics"."name" FROM "ml_candidate_metrics" WHERE "ml_candidate_metrics"."candidate_id" = 2219689 AND "ml_candidate_metrics"."name" > '<name>' ORDER BY "ml_candidate_metrics"."name" ASC LIMIT 1)
UNION
(SELECT (SELECT "ml_candidate_metrics"."name" FROM "ml_candidate_metrics" WHERE "ml_candidate_metrics"."candidate_id" = 2219689 AND "ml_candidate_metrics"."name" > '<name>' AND "ml_candidate_metrics"."name" > "loose_index_scan_cte"."name" ORDER BY "ml_candidate_metrics"."name" ASC LIMIT 1) AS name FROM "loose_index_scan_cte")) SELECT name FROM "loose_index_scan_cte" AS "ml_candidate_metrics" WHERE "ml_candidate_metrics"."name" IS NOT NULL LIMIT 51) names CROSS JOIN LATERAL (SELECT "ml_candidate_metrics".* FROM "ml_candidate_metrics" WHERE "ml_candidate_metrics"."candidate_id" = 2219689 AND (ml_candidate_metrics.name = names.name) ORDER BY "ml_candidate_metrics"."id" DESC LIMIT 1) ml_candidate_metrics ORDER BY "ml_candidate_metrics"."name" ASC

The first page has no name > ... condition.

Run 2219689 (most rows), first page, first run (Time: 12.842 ms, hits: 219 (~1.70 MiB), reads: 18 (~144.00 KiB)), console
 Sort  (cost=133.05..133.18 rows=51 width=114) (actual time=11.709..11.713 rows=25 loops=1)
   Sort Key: ml_candidate_metrics_1.name
   Sort Method: quicksort  Memory: 27kB
   Buffers: shared hit=219 read=18
   I/O Timings: read=10.786 write=0.000
   ->  Nested Loop  (cost=64.55..131.61 rows=51 width=114) (actual time=0.807..11.671 rows=25 loops=1)
         Buffers: shared hit=216 read=18
         I/O Timings: read=10.786 write=0.000
         ->  Limit  (cost=63.98..65.01 rows=51 width=32) (actual time=0.063..10.032 rows=25 loops=1)
               Buffers: shared hit=93 read=16
               I/O Timings: read=9.394 write=0.000
               CTE loose_index_scan_cte
                 ->  Recursive Union  (cost=0.56..63.98 rows=101 width=32) (actual time=0.061..10.013 rows=26 loops=1)
                       Buffers: shared hit=93 read=16
                       I/O Timings: read=9.394 write=0.000
                       ->  Limit  (cost=0.56..0.60 rows=1 width=22) (actual time=0.060..0.061 rows=1 loops=1)
                             Buffers: shared hit=8
                             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_3  (cost=0.56..20227.06 rows=579181 width=22) (actual time=0.060..0.060 rows=1 loops=1)
                                   Index Cond: (ml_candidate_metrics_3.candidate_id = 2219689)
                                   Heap Fetches: 0
                                   Buffers: shared hit=8
                                   I/O Timings: read=0.000 write=0.000
                       ->  WorkTable Scan on loose_index_scan_cte  (cost=0.00..6.24 rows=10 width=32) (actual time=0.381..0.381 rows=1 loops=26)
                             Buffers: shared hit=85 read=16
                             I/O Timings: read=9.394 write=0.000
                             SubPlan 1
                               ->  Limit  (cost=0.56..0.60 rows=1 width=22) (actual time=0.380..0.380 rows=1 loops=26)
                                     Buffers: shared hit=85 read=16
                                     I/O Timings: read=9.394 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_2  (cost=0.56..7475.18 rows=193060 width=22) (actual time=0.380..0.380 rows=1 loops=26)
                                           Index Cond: ((ml_candidate_metrics_2.candidate_id = 2219689) AND (ml_candidate_metrics_2.name > loose_index_scan_cte.name))
                                           Heap Fetches: 0
                                           Buffers: shared hit=85 read=16
                                           I/O Timings: read=9.394 write=0.000
               ->  CTE Scan on loose_index_scan_cte ml_candidate_metrics  (cost=0.00..2.02 rows=100 width=32) (actual time=0.062..10.026 rows=25 loops=1)
                     Filter: (ml_candidate_metrics.name IS NOT NULL)
                     Rows Removed by Filter: 1
                     Buffers: shared hit=93 read=16
                     I/O Timings: read=9.394 write=0.000
         ->  Limit  (cost=0.56..1.30 rows=1 width=114) (actual time=0.065..0.065 rows=1 loops=25)
               Buffers: shared hit=123 read=2
               I/O Timings: read=1.392 write=0.000
               ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics ml_candidate_metrics_1  (cost=0.56..74.38 rows=101 width=114) (actual time=0.064..0.064 rows=1 loops=25)
                     Index Cond: ((ml_candidate_metrics_1.candidate_id = 2219689) AND (ml_candidate_metrics_1.name = ml_candidate_metrics.name))
                     Buffers: shared hit=123 read=2
                     I/O Timings: read=1.392 write=0.000
Run 2219689 (most rows), first page, second run (Time: 1.952 ms, hits: 237 (~1.90 MiB), reads: 0), console
 Sort  (cost=133.05..133.18 rows=51 width=114) (actual time=0.721..0.725 rows=25 loops=1)
   Sort Key: ml_candidate_metrics_1.name
   Sort Method: quicksort  Memory: 27kB
   Buffers: shared hit=237
   I/O Timings: read=0.000 write=0.000
   ->  Nested Loop  (cost=64.55..131.61 rows=51 width=114) (actual time=0.087..0.691 rows=25 loops=1)
         Buffers: shared hit=234
         I/O Timings: read=0.000 write=0.000
         ->  Limit  (cost=63.98..65.01 rows=51 width=32) (actual time=0.064..0.519 rows=25 loops=1)
               Buffers: shared hit=109
               I/O Timings: read=0.000 write=0.000
               CTE loose_index_scan_cte
                 ->  Recursive Union  (cost=0.56..63.98 rows=101 width=32) (actual time=0.062..0.508 rows=26 loops=1)
                       Buffers: shared hit=109
                       I/O Timings: read=0.000 write=0.000
                       ->  Limit  (cost=0.56..0.60 rows=1 width=22) (actual time=0.060..0.061 rows=1 loops=1)
                             Buffers: shared hit=8
                             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_3  (cost=0.56..20227.06 rows=579181 width=22) (actual time=0.060..0.061 rows=1 loops=1)
                                   Index Cond: (ml_candidate_metrics_3.candidate_id = 2219689)
                                   Heap Fetches: 0
                                   Buffers: shared hit=8
                                   I/O Timings: read=0.000 write=0.000
                       ->  WorkTable Scan on loose_index_scan_cte  (cost=0.00..6.24 rows=10 width=32) (actual time=0.016..0.017 rows=1 loops=26)
                             Buffers: shared hit=101
                             I/O Timings: read=0.000 write=0.000
                             SubPlan 1
                               ->  Limit  (cost=0.56..0.60 rows=1 width=22) (actual time=0.016..0.016 rows=1 loops=26)
                                     Buffers: shared hit=101
                                     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_2  (cost=0.56..7475.18 rows=193060 width=22) (actual time=0.016..0.016 rows=1 loops=26)
                                           Index Cond: ((ml_candidate_metrics_2.candidate_id = 2219689) AND (ml_candidate_metrics_2.name > loose_index_scan_cte.name))
                                           Heap Fetches: 0
                                           Buffers: shared hit=101
                                           I/O Timings: read=0.000 write=0.000
               ->  CTE Scan on loose_index_scan_cte ml_candidate_metrics  (cost=0.00..2.02 rows=100 width=32) (actual time=0.063..0.515 rows=25 loops=1)
                     Filter: (ml_candidate_metrics.name IS NOT NULL)
                     Rows Removed by Filter: 1
                     Buffers: shared hit=109
                     I/O Timings: read=0.000 write=0.000
         ->  Limit  (cost=0.56..1.30 rows=1 width=114) (actual time=0.006..0.006 rows=1 loops=25)
               Buffers: shared hit=125
               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 ml_candidate_metrics_1  (cost=0.56..74.38 rows=101 width=114) (actual time=0.006..0.006 rows=1 loops=25)
                     Index Cond: ((ml_candidate_metrics_1.candidate_id = 2219689) AND (ml_candidate_metrics_1.name = ml_candidate_metrics.name))
                     Buffers: shared hit=125
                     I/O Timings: read=0.000 write=0.000
Run 4309014 (most names), first page, first run (Time: 5.258 ms, hits: 464 (~3.60 MiB), reads: 3 (~24.00 KiB)), console
 Sort  (cost=133.83..133.96 rows=51 width=114) (actual time=3.910..3.915 rows=51 loops=1)
   Sort Key: ml_candidate_metrics_1.name
   Sort Method: quicksort  Memory: 30kB
   Buffers: shared hit=464 read=3
   I/O Timings: read=2.631 write=0.000
   ->  Nested Loop  (cost=64.57..132.39 rows=51 width=114) (actual time=1.087..3.859 rows=51 loops=1)
         Buffers: shared hit=461 read=3
         I/O Timings: read=2.631 write=0.000
         ->  Limit  (cost=64.00..65.03 rows=51 width=32) (actual time=0.094..0.736 rows=51 loops=1)
               Buffers: shared hit=209
               I/O Timings: read=0.000 write=0.000
               CTE loose_index_scan_cte
                 ->  Recursive Union  (cost=0.56..64.00 rows=101 width=32) (actual time=0.092..0.713 rows=51 loops=1)
                       Buffers: shared hit=209
                       I/O Timings: read=0.000 write=0.000
                       ->  Limit  (cost=0.56..0.60 rows=1 width=22) (actual time=0.090..0.091 rows=1 loops=1)
                             Buffers: shared hit=8
                             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_3  (cost=0.56..15527.08 rows=439472 width=22) (actual time=0.090..0.090 rows=1 loops=1)
                                   Index Cond: (ml_candidate_metrics_3.candidate_id = 4309014)
                                   Heap Fetches: 0
                                   Buffers: shared hit=8
                                   I/O Timings: read=0.000 write=0.000
                       ->  WorkTable Scan on loose_index_scan_cte  (cost=0.00..6.24 rows=10 width=32) (actual time=0.012..0.012 rows=1 loops=50)
                             Buffers: shared hit=201
                             I/O Timings: read=0.000 write=0.000
                             SubPlan 1
                               ->  Limit  (cost=0.56..0.60 rows=1 width=22) (actual time=0.011..0.011 rows=1 loops=50)
                                     Buffers: shared hit=201
                                     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_2  (cost=0.56..5702.95 rows=146491 width=22) (actual time=0.011..0.011 rows=1 loops=50)
                                           Index Cond: ((ml_candidate_metrics_2.candidate_id = 4309014) AND (ml_candidate_metrics_2.name > loose_index_scan_cte.name))
                                           Heap Fetches: 0
                                           Buffers: shared hit=201
                                           I/O Timings: read=0.000 write=0.000
               ->  CTE Scan on loose_index_scan_cte ml_candidate_metrics  (cost=0.00..2.02 rows=100 width=32) (actual time=0.093..0.729 rows=51 loops=1)
                     Filter: (ml_candidate_metrics.name IS NOT NULL)
                     Buffers: shared hit=209
                     I/O Timings: read=0.000 write=0.000
         ->  Limit  (cost=0.56..1.31 rows=1 width=114) (actual time=0.061..0.061 rows=1 loops=51)
               Buffers: shared hit=252 read=3
               I/O Timings: read=2.631 write=0.000
               ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics ml_candidate_metrics_1  (cost=0.56..57.23 rows=76 width=114) (actual time=0.060..0.060 rows=1 loops=51)
                     Index Cond: ((ml_candidate_metrics_1.candidate_id = 4309014) AND (ml_candidate_metrics_1.name = ml_candidate_metrics.name))
                     Buffers: shared hit=252 read=3
                     I/O Timings: read=2.631 write=0.000
Run 4309014 (most names), first page, second run (Time: 2.706 ms, hits: 467 (~3.60 MiB), reads: 0), console
 Sort  (cost=133.83..133.96 rows=51 width=114) (actual time=1.357..1.362 rows=51 loops=1)
   Sort Key: ml_candidate_metrics_1.name
   Sort Method: quicksort  Memory: 30kB
   Buffers: shared hit=467
   I/O Timings: read=0.000 write=0.000
   ->  Nested Loop  (cost=64.57..132.39 rows=51 width=114) (actual time=0.096..1.297 rows=51 loops=1)
         Buffers: shared hit=464
         I/O Timings: read=0.000 write=0.000
         ->  Limit  (cost=64.00..65.03 rows=51 width=32) (actual time=0.080..0.785 rows=51 loops=1)
               Buffers: shared hit=209
               I/O Timings: read=0.000 write=0.000
               CTE loose_index_scan_cte
                 ->  Recursive Union  (cost=0.56..64.00 rows=101 width=32) (actual time=0.077..0.760 rows=51 loops=1)
                       Buffers: shared hit=209
                       I/O Timings: read=0.000 write=0.000
                       ->  Limit  (cost=0.56..0.60 rows=1 width=22) (actual time=0.075..0.076 rows=1 loops=1)
                             Buffers: shared hit=8
                             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_3  (cost=0.56..15527.08 rows=439472 width=22) (actual time=0.075..0.075 rows=1 loops=1)
                                   Index Cond: (ml_candidate_metrics_3.candidate_id = 4309014)
                                   Heap Fetches: 0
                                   Buffers: shared hit=8
                                   I/O Timings: read=0.000 write=0.000
                       ->  WorkTable Scan on loose_index_scan_cte  (cost=0.00..6.24 rows=10 width=32) (actual time=0.013..0.013 rows=1 loops=50)
                             Buffers: shared hit=201
                             I/O Timings: read=0.000 write=0.000
                             SubPlan 1
                               ->  Limit  (cost=0.56..0.60 rows=1 width=22) (actual time=0.012..0.012 rows=1 loops=50)
                                     Buffers: shared hit=201
                                     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_2  (cost=0.56..5702.95 rows=146491 width=22) (actual time=0.012..0.012 rows=1 loops=50)
                                           Index Cond: ((ml_candidate_metrics_2.candidate_id = 4309014) AND (ml_candidate_metrics_2.name > loose_index_scan_cte.name))
                                           Heap Fetches: 0
                                           Buffers: shared hit=201
                                           I/O Timings: read=0.000 write=0.000
               ->  CTE Scan on loose_index_scan_cte ml_candidate_metrics  (cost=0.00..2.02 rows=100 width=32) (actual time=0.079..0.777 rows=51 loops=1)
                     Filter: (ml_candidate_metrics.name IS NOT NULL)
                     Buffers: shared hit=209
                     I/O Timings: read=0.000 write=0.000
         ->  Limit  (cost=0.56..1.31 rows=1 width=114) (actual time=0.009..0.010 rows=1 loops=51)
               Buffers: shared hit=255
               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 ml_candidate_metrics_1  (cost=0.56..57.23 rows=76 width=114) (actual time=0.009..0.009 rows=1 loops=51)
                     Index Cond: ((ml_candidate_metrics_1.candidate_id = 4309014) AND (ml_candidate_metrics_1.name = ml_candidate_metrics.name))
                     Buffers: shared hit=255
                     I/O Timings: read=0.000 write=0.000
Run 4309014 (most names), page after name 2,591, first run (Time: 8.008 ms, hits: 456 (~3.60 MiB), reads: 7 (~56.00 KiB)), console
 Sort  (cost=134.09..134.21 rows=51 width=114) (actual time=6.351..6.357 rows=50 loops=1)
   Sort Key: ml_candidate_metrics_1.name
   Sort Method: quicksort  Memory: 31kB
   Buffers: shared hit=456 read=7
   I/O Timings: read=5.049 write=0.000
   ->  Nested Loop  (cost=64.82..132.64 rows=51 width=114) (actual time=1.595..6.298 rows=50 loops=1)
         Buffers: shared hit=453 read=7
         I/O Timings: read=5.049 write=0.000
         ->  Limit  (cost=64.26..65.29 rows=51 width=32) (actual time=0.804..3.526 rows=50 loops=1)
               Buffers: shared hit=206 read=4
               I/O Timings: read=2.682 write=0.000
               CTE l
                 ->  Recursive Union  (cost=0.56..64.26 rows=101 width=32) (actual time=0.800..3.492 rows=51 loops=1)
                       Buffers: shared hit=206 read=4
                       I/O Timings: read=2.682 write=0.000
                       ->  Limit  (cost=0.56..0.60 rows=1 width=22) (actual time=0.797..0.798 rows=1 loops=1)
                             Buffers: shared hit=7 read=1
                             I/O Timings: read=0.668 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_3  (cost=0.56..7706.44 rows=199165 width=22) (actual time=0.797..0.797 rows=1 loops=1)
                                   Index Cond: ((ml_candidate_metrics_3.candidate_id = 4309014) AND (ml_candidate_metrics_3.name > '<name>'::text))
                                   Heap Fetches: 0
                                   Buffers: shared hit=7 read=1
                                   I/O Timings: read=0.668 write=0.000
                       ->  WorkTable Scan on l  (cost=0.00..6.26 rows=10 width=32) (actual time=0.052..0.052 rows=1 loops=51)
                             Buffers: shared hit=199 read=3
                             I/O Timings: read=2.014 write=0.000
                             SubPlan 1
                               ->  Limit  (cost=0.56..0.61 rows=1 width=22) (actual time=0.051..0.051 rows=1 loops=51)
                                     Buffers: shared hit=199 read=3
                                     I/O Timings: read=2.014 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_2  (cost=0.56..6069.18 rows=146491 width=22) (actual time=0.051..0.051 rows=1 loops=51)
                                           Index Cond: ((ml_candidate_metrics_2.candidate_id = 4309014) AND (ml_candidate_metrics_2.name > '<name>'::text) AND (ml_candidate_metrics_2.name > l.name))
                                           Heap Fetches: 0
                                           Buffers: shared hit=199 read=3
                                           I/O Timings: read=2.014 write=0.000
               ->  CTE Scan on l ml_candidate_metrics  (cost=0.00..2.02 rows=100 width=32) (actual time=0.803..3.518 rows=50 loops=1)
                     Filter: (ml_candidate_metrics.name IS NOT NULL)
                     Rows Removed by Filter: 1
                     Buffers: shared hit=206 read=4
                     I/O Timings: read=2.682 write=0.000
         ->  Limit  (cost=0.56..1.31 rows=1 width=114) (actual time=0.055..0.055 rows=1 loops=50)
               Buffers: shared hit=247 read=3
               I/O Timings: read=2.367 write=0.000
               ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics ml_candidate_metrics_1  (cost=0.56..57.23 rows=76 width=114) (actual time=0.054..0.054 rows=1 loops=50)
                     Index Cond: ((ml_candidate_metrics_1.candidate_id = 4309014) AND (ml_candidate_metrics_1.name = ml_candidate_metrics.name))
                     Buffers: shared hit=247 read=3
                     I/O Timings: read=2.367 write=0.000
Run 4309014 (most names), page after name 2,591, second run (Time: 2.894 ms, hits: 463 (~3.60 MiB), reads: 0), console
 Sort  (cost=134.09..134.21 rows=51 width=114) (actual time=1.242..1.247 rows=50 loops=1)
   Sort Key: ml_candidate_metrics_1.name
   Sort Method: quicksort  Memory: 31kB
   Buffers: shared hit=463
   I/O Timings: read=0.000 write=0.000
   ->  Nested Loop  (cost=64.82..132.64 rows=51 width=114) (actual time=0.121..1.152 rows=50 loops=1)
         Buffers: shared hit=460
         I/O Timings: read=0.000 write=0.000
         ->  Limit  (cost=64.26..65.29 rows=51 width=32) (actual time=0.105..0.784 rows=50 loops=1)
               Buffers: shared hit=210
               I/O Timings: read=0.000 write=0.000
               CTE l
                 ->  Recursive Union  (cost=0.56..64.26 rows=101 width=32) (actual time=0.102..0.759 rows=51 loops=1)
                       Buffers: shared hit=210
                       I/O Timings: read=0.000 write=0.000
                       ->  Limit  (cost=0.56..0.60 rows=1 width=22) (actual time=0.101..0.101 rows=1 loops=1)
                             Buffers: shared hit=8
                             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_3  (cost=0.56..7706.44 rows=199165 width=22) (actual time=0.100..0.101 rows=1 loops=1)
                                   Index Cond: ((ml_candidate_metrics_3.candidate_id = 4309014) AND (ml_candidate_metrics_3.name > '<name>'::text))
                                   Heap Fetches: 0
                                   Buffers: shared hit=8
                                   I/O Timings: read=0.000 write=0.000
                       ->  WorkTable Scan on l  (cost=0.00..6.26 rows=10 width=32) (actual time=0.012..0.012 rows=1 loops=51)
                             Buffers: shared hit=202
                             I/O Timings: read=0.000 write=0.000
                             SubPlan 1
                               ->  Limit  (cost=0.56..0.61 rows=1 width=22) (actual time=0.012..0.012 rows=1 loops=51)
                                     Buffers: shared hit=202
                                     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_2  (cost=0.56..6069.18 rows=146491 width=22) (actual time=0.011..0.011 rows=1 loops=51)
                                           Index Cond: ((ml_candidate_metrics_2.candidate_id = 4309014) AND (ml_candidate_metrics_2.name > '<name>'::text) AND (ml_candidate_metrics_2.name > l.name))
                                           Heap Fetches: 0
                                           Buffers: shared hit=202
                                           I/O Timings: read=0.000 write=0.000
               ->  CTE Scan on l ml_candidate_metrics  (cost=0.00..2.02 rows=100 width=32) (actual time=0.104..0.778 rows=50 loops=1)
                     Filter: (ml_candidate_metrics.name IS NOT NULL)
                     Rows Removed by Filter: 1
                     Buffers: shared hit=210
                     I/O Timings: read=0.000 write=0.000
         ->  Limit  (cost=0.56..1.31 rows=1 width=114) (actual time=0.007..0.007 rows=1 loops=50)
               Buffers: shared hit=250
               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 ml_candidate_metrics_1  (cost=0.56..57.23 rows=76 width=114) (actual time=0.007..0.007 rows=1 loops=50)
                     Index Cond: ((ml_candidate_metrics_1.candidate_id = 4309014) AND (ml_candidate_metrics_1.name = ml_candidate_metrics.name))
                     Buffers: shared hit=250
                     I/O Timings: read=0.000 write=0.000
Run 4305254, first page, first run (Time: 27.550 ms, hits: 431 (~3.40 MiB), reads: 38 (~304.00 KiB)), console
 Sort  (cost=251.79..251.91 rows=51 width=114) (actual time=26.305..26.311 rows=51 loops=1)
   Sort Key: ml_candidate_metrics_1.name
   Sort Method: quicksort  Memory: 30kB
   Buffers: shared hit=431 read=38
   I/O Timings: read=25.047 write=0.000
   ->  Nested Loop  (cost=66.53..250.34 rows=51 width=114) (actual time=1.962..26.232 rows=51 loops=1)
         Buffers: shared hit=428 read=38
         I/O Timings: read=25.047 write=0.000
         ->  Limit  (cost=65.96..66.99 rows=51 width=32) (actual time=1.085..1.670 rows=51 loops=1)
               Buffers: shared hit=210 read=1
               I/O Timings: read=0.971 write=0.000
               CTE loose_index_scan_cte
                 ->  Recursive Union  (cost=0.56..65.96 rows=101 width=32) (actual time=1.082..1.626 rows=51 loops=1)
                       Buffers: shared hit=210 read=1
                       I/O Timings: read=0.971 write=0.000
                       ->  Limit  (cost=0.56..0.61 rows=1 width=22) (actual time=1.079..1.080 rows=1 loops=1)
                             Buffers: shared hit=7 read=1
                             I/O Timings: read=0.971 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_3  (cost=0.56..10.49 rows=234 width=22) (actual time=1.078..1.078 rows=1 loops=1)
                                   Index Cond: (ml_candidate_metrics_3.candidate_id = 4305254)
                                   Heap Fetches: 0
                                   Buffers: shared hit=7 read=1
                                   I/O Timings: read=0.971 write=0.000
                       ->  WorkTable Scan on loose_index_scan_cte  (cost=0.00..6.43 rows=10 width=32) (actual time=0.009..0.009 rows=1 loops=50)
                             Buffers: shared hit=203
                             I/O Timings: read=0.000 write=0.000
                             SubPlan 1
                               ->  Limit  (cost=0.56..0.62 rows=1 width=22) (actual time=0.008..0.008 rows=1 loops=50)
                                     Buffers: shared hit=203
                                     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_2  (cost=0.56..5.12 rows=78 width=22) (actual time=0.008..0.008 rows=1 loops=50)
                                           Index Cond: ((ml_candidate_metrics_2.candidate_id = 4305254) AND (ml_candidate_metrics_2.name > loose_index_scan_cte.name))
                                           Heap Fetches: 1
                                           Buffers: shared hit=203
                                           I/O Timings: read=0.000 write=0.000
               ->  CTE Scan on loose_index_scan_cte ml_candidate_metrics  (cost=0.00..2.02 rows=100 width=32) (actual time=1.084..1.657 rows=51 loops=1)
                     Filter: (ml_candidate_metrics.name IS NOT NULL)
                     Buffers: shared hit=210 read=1
                     I/O Timings: read=0.971 write=0.000
         ->  Limit  (cost=0.56..3.58 rows=1 width=114) (actual time=0.481..0.481 rows=1 loops=51)
               Buffers: shared hit=218 read=37
               I/O Timings: read=24.076 write=0.000
               ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics ml_candidate_metrics_1  (cost=0.56..3.58 rows=1 width=114) (actual time=0.480..0.480 rows=1 loops=51)
                     Index Cond: ((ml_candidate_metrics_1.candidate_id = 4305254) AND (ml_candidate_metrics_1.name = ml_candidate_metrics.name))
                     Buffers: shared hit=218 read=37
                     I/O Timings: read=24.076 write=0.000
Run 4305254, first page, second run (Time: 1.839 ms, hits: 469 (~3.70 MiB), reads: 0), console
 Sort  (cost=251.79..251.91 rows=51 width=114) (actual time=0.679..0.683 rows=51 loops=1)
   Sort Key: ml_candidate_metrics_1.name
   Sort Method: quicksort  Memory: 30kB
   Buffers: shared hit=469
   I/O Timings: read=0.000 write=0.000
   ->  Nested Loop  (cost=66.53..250.34 rows=51 width=114) (actual time=0.087..0.629 rows=51 loops=1)
         Buffers: shared hit=466
         I/O Timings: read=0.000 write=0.000
         ->  Limit  (cost=65.96..66.99 rows=51 width=32) (actual time=0.074..0.372 rows=51 loops=1)
               Buffers: shared hit=211
               I/O Timings: read=0.000 write=0.000
               CTE loose_index_scan_cte
                 ->  Recursive Union  (cost=0.56..65.96 rows=101 width=32) (actual time=0.072..0.353 rows=51 loops=1)
                       Buffers: shared hit=211
                       I/O Timings: read=0.000 write=0.000
                       ->  Limit  (cost=0.56..0.61 rows=1 width=22) (actual time=0.071..0.071 rows=1 loops=1)
                             Buffers: shared hit=8
                             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_3  (cost=0.56..10.49 rows=234 width=22) (actual time=0.070..0.071 rows=1 loops=1)
                                   Index Cond: (ml_candidate_metrics_3.candidate_id = 4305254)
                                   Heap Fetches: 0
                                   Buffers: shared hit=8
                                   I/O Timings: read=0.000 write=0.000
                       ->  WorkTable Scan on loose_index_scan_cte  (cost=0.00..6.43 rows=10 width=32) (actual time=0.005..0.005 rows=1 loops=50)
                             Buffers: shared hit=203
                             I/O Timings: read=0.000 write=0.000
                             SubPlan 1
                               ->  Limit  (cost=0.56..0.62 rows=1 width=22) (actual time=0.005..0.005 rows=1 loops=50)
                                     Buffers: shared hit=203
                                     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_2  (cost=0.56..5.12 rows=78 width=22) (actual time=0.004..0.004 rows=1 loops=50)
                                           Index Cond: ((ml_candidate_metrics_2.candidate_id = 4305254) AND (ml_candidate_metrics_2.name > loose_index_scan_cte.name))
                                           Heap Fetches: 1
                                           Buffers: shared hit=203
                                           I/O Timings: read=0.000 write=0.000
               ->  CTE Scan on loose_index_scan_cte ml_candidate_metrics  (cost=0.00..2.02 rows=100 width=32) (actual time=0.073..0.366 rows=51 loops=1)
                     Filter: (ml_candidate_metrics.name IS NOT NULL)
                     Buffers: shared hit=211
                     I/O Timings: read=0.000 write=0.000
         ->  Limit  (cost=0.56..3.58 rows=1 width=114) (actual time=0.005..0.005 rows=1 loops=51)
               Buffers: shared hit=255
               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 ml_candidate_metrics_1  (cost=0.56..3.58 rows=1 width=114) (actual time=0.004..0.004 rows=1 loops=51)
                     Index Cond: ((ml_candidate_metrics_1.candidate_id = 4305254) AND (ml_candidate_metrics_1.name = ml_candidate_metrics.name))
                     Buffers: shared hit=255
                     I/O Timings: read=0.000 write=0.000

2. history: the newest values of each name on the page

SELECT "ml_candidate_metrics".* FROM unnest(ARRAY['<name 1>','<name 2>']::text[]) names(name) CROSS JOIN LATERAL (SELECT "ml_candidate_metrics".* FROM "ml_candidate_metrics" WHERE "ml_candidate_metrics"."candidate_id" = 2219689 AND (ml_candidate_metrics.name = names.name) ORDER BY "ml_candidate_metrics"."id" DESC LIMIT 101) ml_candidate_metrics ORDER BY "ml_candidate_metrics"."name" ASC, "ml_candidate_metrics"."id" DESC
Run 2219689 (most rows), its 25 names, first run (Time: 121.718 ms, hits: 2148 (~16.80 MiB), reads: 168 (~1.30 MiB)), console
 Sort  (cost=860.23..862.76 rows=1010 width=114) (actual time=120.564..120.678 rows=2525 loops=1)
   Sort Key: ml_candidate_metrics.name, ml_candidate_metrics.id DESC
   Sort Method: quicksort  Memory: 376kB
   Buffers: shared hit=2148 read=168
   I/O Timings: read=115.950 write=0.000
   InitPlan 1
     ->  Seq Scan on public.z640899  (cost=0.00..55.88 rows=6 width=32) (actual time=0.025..0.028 rows=25 loops=1)
           Filter: (z640899.c = 2219689)
           Rows Removed by Filter: 50
           Buffers: shared hit=1
           I/O Timings: read=0.000 write=0.000
   ->  Nested Loop  (cost=0.57..753.96 rows=1010 width=114) (actual time=0.093..119.464 rows=2525 loops=1)
         Buffers: shared hit=2142 read=168
         I/O Timings: read=115.950 write=0.000
         ->  Function Scan on pg_catalog.unnest names  (cost=0.00..0.10 rows=10 width=32) (actual time=0.049..0.057 rows=25 loops=1)
               Function Call: unnest((InitPlan 1).col1)
               Buffers: shared hit=1
               I/O Timings: read=0.000 write=0.000
         ->  Limit  (cost=0.56..74.38 rows=101 width=114) (actual time=0.022..4.755 rows=101 loops=25)
               Buffers: shared hit=2141 read=168
               I/O Timings: read=115.950 write=0.000
               ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..74.38 rows=101 width=114) (actual time=0.021..4.744 rows=101 loops=25)
                     Index Cond: ((ml_candidate_metrics.candidate_id = 2219689) AND (ml_candidate_metrics.name = names.name))
                     Buffers: shared hit=2141 read=168
                     I/O Timings: read=115.950 write=0.000
Run 2219689 (most rows), its 25 names, second run (Time: 9.480 ms, hits: 2316 (~18.10 MiB), reads: 0), console
 Sort  (cost=809.29..811.82 rows=1010 width=114) (actual time=7.412..7.561 rows=2525 loops=1)
   Sort Key: ml_candidate_metrics.name, ml_candidate_metrics.id DESC
   Sort Method: quicksort  Memory: 376kB
   Buffers: shared hit=2316
   I/O Timings: read=0.000 write=0.000
   InitPlan 1
     ->  Seq Scan on public.z640899  (cost=0.00..4.94 rows=25 width=28) (actual time=0.012..0.015 rows=25 loops=1)
           Filter: (z640899.c = 2219689)
           Rows Removed by Filter: 50
           Buffers: shared hit=1
           I/O Timings: read=0.000 write=0.000
   ->  Nested Loop  (cost=0.57..753.96 rows=1010 width=114) (actual time=0.091..4.775 rows=2525 loops=1)
         Buffers: shared hit=2310
         I/O Timings: read=0.000 write=0.000
         ->  Function Scan on pg_catalog.unnest names  (cost=0.00..0.10 rows=10 width=32) (actual time=0.038..0.042 rows=25 loops=1)
               Function Call: unnest((InitPlan 1).col1)
               Buffers: shared hit=1
               I/O Timings: read=0.000 write=0.000
         ->  Limit  (cost=0.56..74.38 rows=101 width=114) (actual time=0.030..0.155 rows=101 loops=25)
               Buffers: shared hit=2309
               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..74.38 rows=101 width=114) (actual time=0.030..0.138 rows=101 loops=25)
                     Index Cond: ((ml_candidate_metrics.candidate_id = 2219689) AND (ml_candidate_metrics.name = names.name))
                     Buffers: shared hit=2309
                     I/O Timings: read=0.000 write=0.000
Run 4309014 (most names), first 50 names, first run (Time: 177.852 ms, hits: 4509 (~35.20 MiB), reads: 188 (~1.50 MiB)), console
 Sort  (cost=621.35..623.25 rows=760 width=114) (actual time=175.240..175.452 rows=4450 loops=1)
   Sort Key: ml_candidate_metrics.name, ml_candidate_metrics.id DESC
   Sort Method: quicksort  Memory: 695kB
   Buffers: shared hit=4509 read=188
   I/O Timings: read=162.984 write=0.000
   InitPlan 1
     ->  Seq Scan on public.z640899  (cost=0.00..4.94 rows=50 width=28) (actual time=0.008..0.015 rows=50 loops=1)
           Filter: (z640899.c = 4309014)
           Rows Removed by Filter: 25
           Buffers: shared hit=1
           I/O Timings: read=0.000 write=0.000
   ->  Nested Loop  (cost=0.57..580.04 rows=760 width=114) (actual time=0.116..171.158 rows=4450 loops=1)
         Buffers: shared hit=4503 read=188
         I/O Timings: read=162.984 write=0.000
         ->  Function Scan on pg_catalog.unnest names  (cost=0.00..0.10 rows=10 width=32) (actual time=0.062..0.080 rows=50 loops=1)
               Function Call: unnest((InitPlan 1).col1)
               Buffers: shared hit=1
               I/O Timings: read=0.000 write=0.000
         ->  Limit  (cost=0.56..57.23 rows=76 width=114) (actual time=0.035..3.395 rows=89 loops=50)
               Buffers: shared hit=4502 read=188
               I/O Timings: read=162.984 write=0.000
               ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..57.23 rows=76 width=114) (actual time=0.034..3.380 rows=89 loops=50)
                     Index Cond: ((ml_candidate_metrics.candidate_id = 4309014) AND (ml_candidate_metrics.name = names.name))
                     Buffers: shared hit=4502 read=188
                     I/O Timings: read=162.984 write=0.000
Run 4309014 (most names), first 50 names, second run (Time: 9.757 ms, hits: 4697 (~36.70 MiB), reads: 0), console
 Sort  (cost=621.35..623.25 rows=760 width=114) (actual time=7.874..8.153 rows=4450 loops=1)
   Sort Key: ml_candidate_metrics.name, ml_candidate_metrics.id DESC
   Sort Method: quicksort  Memory: 695kB
   Buffers: shared hit=4697
   I/O Timings: read=0.000 write=0.000
   InitPlan 1
     ->  Seq Scan on public.z640899  (cost=0.00..4.94 rows=50 width=28) (actual time=0.007..0.015 rows=50 loops=1)
           Filter: (z640899.c = 4309014)
           Rows Removed by Filter: 25
           Buffers: shared hit=1
           I/O Timings: read=0.000 write=0.000
   ->  Nested Loop  (cost=0.57..580.04 rows=760 width=114) (actual time=0.096..5.329 rows=4450 loops=1)
         Buffers: shared hit=4691
         I/O Timings: read=0.000 write=0.000
         ->  Function Scan on pg_catalog.unnest names  (cost=0.00..0.10 rows=10 width=32) (actual time=0.043..0.051 rows=50 loops=1)
               Function Call: unnest((InitPlan 1).col1)
               Buffers: shared hit=1
               I/O Timings: read=0.000 write=0.000
         ->  Limit  (cost=0.56..57.23 rows=76 width=114) (actual time=0.014..0.079 rows=89 loops=50)
               Buffers: shared hit=4690
               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..57.23 rows=76 width=114) (actual time=0.014..0.067 rows=89 loops=50)
                     Index Cond: ((ml_candidate_metrics.candidate_id = 4309014) AND (ml_candidate_metrics.name = names.name))
                     Buffers: shared hit=4690
                     I/O Timings: read=0.000 write=0.000

Shipped SQL: the literal array of 50 names and LIMIT 100. The Database Lab CLI cannot take the literal array, so a DO block on the clone builds the statement from a scratch table of names and runs EXPLAIN (ANALYZE, BUFFERS, SETTINGS) on it. These runs have no console links.

Run 4309014 has the most names with at least 100 rows each (1,387). Its first 50 of these names, ordered by name, give the densest page possible: 5,000 rows. Run 4246766 is next (271 names); nothing read its heap on the clone before its first run. The index build had put the index in the cache, so no run read from disk. The earlier first runs above read 168 and 188 blocks from disk in 116 ms and 163 ms (0.7 to 0.9 ms a block). The densest page touches 858 to 5,242 blocks. If none of them is in the cache, that page can take seconds. We accept this cold cost: one page per request, behind the flag, with the rollback thresholds of the rollout issue.

Run 4309014, densest 50 names, LIMIT 100, first run (Planning: 0.350 ms, Execution: 5.663 ms, hits: 5242, reads: 0), Joe command 611854
 Sort  (cost=3009.34..3018.46 rows=3650 width=114) (actual time=5.198..5.432 rows=5000 loops=1)
  Sort Key: ml_candidate_metrics.name, ml_candidate_metrics.id DESC
  Sort Method: quicksort  Memory: 757kB
  Buffers: shared hit=5242
  ->  Nested Loop  (cost=0.57..2793.37 rows=3650 width=114) (actual time=0.034..3.715 rows=5000 loops=1)
        Buffers: shared hit=5242
        ->  Function Scan on unnest names  (cost=0.00..0.50 rows=50 width=32) (actual time=0.010..0.016 rows=50 loops=1)
        ->  Limit  (cost=0.56..55.13 rows=73 width=114) (actual time=0.010..0.055 rows=100 loops=50)
              Buffers: shared hit=5242
              ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on ml_candidate_metrics  (cost=0.56..55.13 rows=73 width=114) (actual time=0.010..0.047 rows=100 loops=50)
                    Index Cond: ((candidate_id = 4309014) AND (name = names.name))
                    Buffers: shared hit=5242
Settings: effective_cache_size = '472585MB', work_mem = '230MB', jit = 'off', random_page_cost = '1.5', seq_page_cost = '4'
Planning:
  Buffers: shared hit=81
Planning Time: 0.350 ms
Execution Time: 5.663 ms
Run 4309014, densest 50 names, LIMIT 100, second run (Planning: 0.153 ms, Execution: 6.288 ms, hits: 5242, reads: 0), Joe command 611856
 Sort  (cost=3009.34..3018.46 rows=3650 width=114) (actual time=5.663..5.978 rows=5000 loops=1)
  Sort Key: ml_candidate_metrics.name, ml_candidate_metrics.id DESC
  Sort Method: quicksort  Memory: 757kB
  Buffers: shared hit=5242
  ->  Nested Loop  (cost=0.57..2793.37 rows=3650 width=114) (actual time=0.029..4.001 rows=5000 loops=1)
        Buffers: shared hit=5242
        ->  Function Scan on unnest names  (cost=0.00..0.50 rows=50 width=32) (actual time=0.006..0.013 rows=50 loops=1)
        ->  Limit  (cost=0.56..55.13 rows=73 width=114) (actual time=0.011..0.060 rows=100 loops=50)
              Buffers: shared hit=5242
              ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on ml_candidate_metrics  (cost=0.56..55.13 rows=73 width=114) (actual time=0.010..0.050 rows=100 loops=50)
                    Index Cond: ((candidate_id = 4309014) AND (name = names.name))
                    Buffers: shared hit=5242
Settings: effective_cache_size = '472585MB', work_mem = '230MB', jit = 'off', random_page_cost = '1.5', seq_page_cost = '4'
Planning Time: 0.153 ms
Execution Time: 6.288 ms
Run 4246766, densest 50 names, LIMIT 100, first run (Planning: 0.159 ms, Execution: 5.670 ms, hits: 756, reads: 102), Joe command 611868
 Sort  (cost=590.16..591.66 rows=600 width=114) (actual time=5.218..5.446 rows=5000 loops=1)
  Sort Key: ml_candidate_metrics.name, ml_candidate_metrics.id DESC
  Sort Method: quicksort  Memory: 735kB
  Buffers: shared hit=756 read=102
  I/O Timings: shared read=1.381
  ->  Nested Loop  (cost=0.57..562.47 rows=600 width=114) (actual time=0.173..4.027 rows=5000 loops=1)
        Buffers: shared hit=756 read=102
        I/O Timings: shared read=1.381
        ->  Function Scan on unnest names  (cost=0.00..0.50 rows=50 width=32) (actual time=0.007..0.013 rows=50 loops=1)
        ->  Limit  (cost=0.56..11.12 rows=12 width=114) (actual time=0.014..0.066 rows=100 loops=50)
              Buffers: shared hit=756 read=102
              I/O Timings: shared read=1.381
              ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on ml_candidate_metrics  (cost=0.56..11.12 rows=12 width=114) (actual time=0.014..0.058 rows=100 loops=50)
                    Index Cond: ((candidate_id = 4246766) AND (name = names.name))
                    Buffers: shared hit=756 read=102
                    I/O Timings: shared read=1.381
Settings: effective_cache_size = '472585MB', work_mem = '230MB', jit = 'off', random_page_cost = '1.5', seq_page_cost = '4'
Planning Time: 0.159 ms
Execution Time: 5.670 ms
Run 4246766, densest 50 names, LIMIT 100, second run (Planning: 0.178 ms, Execution: 4.339 ms, hits: 858, reads: 0), Joe command 611870
 Sort  (cost=590.16..591.66 rows=600 width=114) (actual time=3.862..4.105 rows=5000 loops=1)
  Sort Key: ml_candidate_metrics.name, ml_candidate_metrics.id DESC
  Sort Method: quicksort  Memory: 735kB
  Buffers: shared hit=858
  ->  Nested Loop  (cost=0.57..562.47 rows=600 width=114) (actual time=0.029..2.586 rows=5000 loops=1)
        Buffers: shared hit=858
        ->  Function Scan on unnest names  (cost=0.00..0.50 rows=50 width=32) (actual time=0.007..0.012 rows=50 loops=1)
        ->  Limit  (cost=0.56..11.12 rows=12 width=114) (actual time=0.010..0.036 rows=100 loops=50)
              Buffers: shared hit=858
              ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on ml_candidate_metrics  (cost=0.56..11.12 rows=12 width=114) (actual time=0.010..0.028 rows=100 loops=50)
                    Index Cond: ((candidate_id = 4246766) AND (name = names.name))
                    Buffers: shared hit=858
Settings: effective_cache_size = '472585MB', work_mem = '230MB', jit = 'off', random_page_cost = '1.5', seq_page_cost = '4'
Planning Time: 0.178 ms
Execution Time: 4.339 ms
Run 4309014, densest 50 names, LIMIT 10 (Planning: 0.137 ms, Execution: 0.942 ms, hits: 704) and LIMIT 1 (Planning: 0.159 ms, Execution: 0.570 ms, hits: 250), Joe commands 611858 and 611860
 Sort  (cost=429.88..431.13 rows=500 width=114) (actual time=0.879..0.903 rows=500 loops=1)
  Sort Key: ml_candidate_metrics.name, ml_candidate_metrics.id DESC
  Sort Method: quicksort  Memory: 81kB
  Buffers: shared hit=704
  ->  Nested Loop  (cost=0.57..407.47 rows=500 width=114) (actual time=0.026..0.752 rows=500 loops=1)
        Buffers: shared hit=704
        ->  Function Scan on unnest names  (cost=0.00..0.50 rows=50 width=32) (actual time=0.005..0.009 rows=50 loops=1)
        ->  Limit  (cost=0.56..8.04 rows=10 width=114) (actual time=0.009..0.013 rows=10 loops=50)
              Buffers: shared hit=704
              ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on ml_candidate_metrics  (cost=0.56..55.13 rows=73 width=114) (actual time=0.009..0.012 rows=10 loops=50)
                    Index Cond: ((candidate_id = 4309014) AND (name = names.name))
                    Buffers: shared hit=704
Settings: effective_cache_size = '472585MB', work_mem = '230MB', jit = 'off', random_page_cost = '1.5', seq_page_cost = '4'
Planning Time: 0.137 ms
Execution Time: 0.942 ms

 Sort  (cost=68.03..68.16 rows=50 width=114) (actual time=0.545..0.548 rows=50 loops=1)
  Sort Key: ml_candidate_metrics.name, ml_candidate_metrics.id DESC
  Sort Method: quicksort  Memory: 30kB
  Buffers: shared hit=250
  ->  Nested Loop  (cost=0.57..66.62 rows=50 width=114) (actual time=0.028..0.514 rows=50 loops=1)
        Buffers: shared hit=250
        ->  Function Scan on unnest names  (cost=0.00..0.50 rows=50 width=32) (actual time=0.007..0.010 rows=50 loops=1)
        ->  Limit  (cost=0.56..1.31 rows=1 width=114) (actual time=0.010..0.010 rows=1 loops=50)
              Buffers: shared hit=250
              ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on ml_candidate_metrics  (cost=0.56..55.13 rows=73 width=114) (actual time=0.009..0.009 rows=1 loops=50)
                    Index Cond: ((candidate_id = 4309014) AND (name = names.name))
                    Buffers: shared hit=250
Settings: effective_cache_size = '472585MB', work_mem = '230MB', jit = 'off', random_page_cost = '1.5', seq_page_cost = '4'
Planning Time: 0.159 ms
Execution Time: 0.570 ms

3. metrics(name:): the values of one metric, keyset on id

SELECT "ml_candidate_metrics".* FROM "ml_candidate_metrics" WHERE "ml_candidate_metrics"."candidate_id" = 2219689 AND "ml_candidate_metrics"."name" = '<name>' ORDER BY "ml_candidate_metrics"."id" DESC LIMIT 101

Later pages add AND ("ml_candidate_metrics"."id" < <cursor id>). The plans use the name of run 2219689 with the most rows (44,360), and a cursor at 90% of its history.

First page, first run (Time: 1.309 ms, hits: 84 (~672.00 KiB), reads: 0), console
 Limit  (cost=0.56..73.92 rows=101 width=114) (actual time=0.060..0.252 rows=101 loops=1)
   Buffers: shared hit=84
   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..6802.60 rows=9365 width=114) (actual time=0.060..0.241 rows=101 loops=1)
         Index Cond: ((ml_candidate_metrics.candidate_id = 2219689) AND (ml_candidate_metrics.name = '<name>'::text))
         Buffers: shared hit=84
         I/O Timings: read=0.000 write=0.000
First page, second run (Time: 1.053 ms, hits: 84 (~672.00 KiB), reads: 0), console
 Limit  (cost=0.56..73.92 rows=101 width=114) (actual time=0.065..0.221 rows=101 loops=1)
   Buffers: shared hit=84
   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..6802.60 rows=9365 width=114) (actual time=0.065..0.212 rows=101 loops=1)
         Index Cond: ((ml_candidate_metrics.candidate_id = 2219689) AND (ml_candidate_metrics.name = '<name>'::text))
         Buffers: shared hit=84
         I/O Timings: read=0.000 write=0.000
Page at 90% of the history, first run (Time: 3.529 ms, hits: 98 (~784.00 KiB), reads: 1 (~8.00 KiB)), console
 Limit  (cost=0.56..74.51 rows=101 width=114) (actual time=2.435..2.600 rows=101 loops=1)
   Buffers: shared hit=98 read=1
   I/O Timings: read=2.352 write=0.000
   ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..1852.82 rows=2530 width=114) (actual time=2.434..2.590 rows=101 loops=1)
         Index Cond: ((ml_candidate_metrics.candidate_id = 2219689) AND (ml_candidate_metrics.name = '<name>'::text) AND (ml_candidate_metrics.id < 16690423))
         Buffers: shared hit=98 read=1
         I/O Timings: read=2.352 write=0.000
Page at 90% of the history, second run (Time: 36.822 ms, hits: 48 (~384.00 KiB), reads: 51 (~408.00 KiB)), console
 Limit  (cost=0.56..74.51 rows=101 width=114) (actual time=0.893..35.950 rows=101 loops=1)
   Buffers: shared hit=48 read=51
   I/O Timings: read=35.524 write=0.000
   ->  Index Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..1852.82 rows=2530 width=114) (actual time=0.892..35.936 rows=101 loops=1)
         Index Cond: ((ml_candidate_metrics.candidate_id = 2219689) AND (ml_candidate_metrics.name = '<name>'::text) AND (ml_candidate_metrics.id < 16690423))
         Buffers: shared hit=48 read=51
         I/O Timings: read=35.524 write=0.000

Count and backward pages of metrics(name:)

The connection type is a LimitedCountableConnectionType, so a client can also select count or page backward with last:/before:. Same name and cursor as above, clone with the index.

SELECT COUNT(*) FROM (SELECT 1 AS one FROM "ml_candidate_metrics" WHERE "ml_candidate_metrics"."candidate_id" = 2219689 AND "ml_candidate_metrics"."name" = '<name>' LIMIT 1001) subquery_for_count
SELECT "ml_candidate_metrics".* FROM "ml_candidate_metrics" WHERE "ml_candidate_metrics"."candidate_id" = 2219689 AND "ml_candidate_metrics"."name" = '<name>' ORDER BY "ml_candidate_metrics"."id" ASC LIMIT 101

Pages with before: add AND ("ml_candidate_metrics"."id" > <cursor id>).

Count, first run (Time: 18.754 ms, hits: 66 (~528.00 KiB), reads: 119 (~952.00 KiB)), console
 Aggregate  (cost=51.50..51.51 rows=1 width=8) (actual time=17.939..17.941 rows=1 loops=1)
   Buffers: shared hit=66 read=119 dirtied=107
   I/O Timings: read=16.609 write=0.000
   ->  Limit  (cost=0.56..38.99 rows=1001 width=4) (actual time=0.267..17.881 rows=1001 loops=1)
         Buffers: shared hit=66 read=119 dirtied=107
         I/O Timings: read=16.609 write=0.000
         ->  Index Only Scan using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..368.89 rows=9595 width=4) (actual time=0.266..17.800 rows=1001 loops=1)
               Index Cond: ((ml_candidate_metrics.candidate_id = 2219689) AND (ml_candidate_metrics.name = '<name>'::text))
               Buffers: shared hit=66 read=119 dirtied=107
               I/O Timings: read=16.609 write=0.000
Count, second run (Time: 1.386 ms, hits: 185 (~1.40 MiB), reads: 0), console
 Aggregate  (cost=51.50..51.51 rows=1 width=8) (actual time=0.568..0.568 rows=1 loops=1)
   Buffers: shared hit=185
   I/O Timings: read=0.000 write=0.000
   ->  Limit  (cost=0.56..38.99 rows=1001 width=4) (actual time=0.091..0.517 rows=1001 loops=1)
         Buffers: shared hit=185
         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  (cost=0.56..368.89 rows=9595 width=4) (actual time=0.090..0.448 rows=1001 loops=1)
               Index Cond: ((ml_candidate_metrics.candidate_id = 2219689) AND (ml_candidate_metrics.name = '<name>'::text))
               Buffers: shared hit=185
               I/O Timings: read=0.000 write=0.000
Last page (`last: 100`), first run (Time: 13.496 ms, hits: 25 (~200.00 KiB), reads: 77 (~616.00 KiB)), console
 Limit  (cost=0.56..73.90 rows=101 width=114) (actual time=0.956..12.570 rows=101 loops=1)
   Buffers: shared hit=25 read=77
   I/O Timings: read=12.203 write=0.000
   ->  Index Scan Backward using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..6967.77 rows=9595 width=114) (actual time=0.955..12.558 rows=101 loops=1)
         Index Cond: ((ml_candidate_metrics.candidate_id = 2219689) AND (ml_candidate_metrics.name = '<name>'::text))
         Buffers: shared hit=25 read=77
         I/O Timings: read=12.203 write=0.000
Last page (`last: 100`), second run (Time: 1.252 ms, hits: 102 (~816.00 KiB), reads: 0), console
 Limit  (cost=0.56..73.90 rows=101 width=114) (actual time=0.065..0.249 rows=101 loops=1)
   Buffers: shared hit=102
   I/O Timings: read=0.000 write=0.000
   ->  Index Scan Backward using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..6967.77 rows=9595 width=114) (actual time=0.064..0.240 rows=101 loops=1)
         Index Cond: ((ml_candidate_metrics.candidate_id = 2219689) AND (ml_candidate_metrics.name = '<name>'::text))
         Buffers: shared hit=102
         I/O Timings: read=0.000 write=0.000
Page before the cursor at 90% of the history, first run (Time: 11.170 ms, hits: 40 (~320.00 KiB), reads: 66 (~528.00 KiB)), console
 Limit  (cost=0.56..74.26 rows=101 width=114) (actual time=1.410..10.242 rows=101 loops=1)
   Buffers: shared hit=40 read=66
   I/O Timings: read=9.896 write=0.000
   ->  Index Scan Backward using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..5164.92 rows=7078 width=114) (actual time=1.409..10.226 rows=101 loops=1)
         Index Cond: ((ml_candidate_metrics.candidate_id = 2219689) AND (ml_candidate_metrics.name = '<name>'::text) AND (ml_candidate_metrics.id > 16690423))
         Buffers: shared hit=40 read=66
         I/O Timings: read=9.896 write=0.000
Page before the cursor at 90% of the history, second run (Time: 1.342 ms, hits: 106 (~848.00 KiB), reads: 0), console
 Limit  (cost=0.56..74.26 rows=101 width=114) (actual time=0.073..0.261 rows=101 loops=1)
   Buffers: shared hit=106
   I/O Timings: read=0.000 write=0.000
   ->  Index Scan Backward using index_ml_candidate_metrics_on_candidate_id_name_id_desc on public.ml_candidate_metrics  (cost=0.56..5164.92 rows=7078 width=114) (actual time=0.072..0.252 rows=101 loops=1)
         Index Cond: ((ml_candidate_metrics.candidate_id = 2219689) AND (ml_candidate_metrics.name = '<name>'::text) AND (ml_candidate_metrics.id > 16690423))
         Buffers: shared hit=106
         I/O Timings: read=0.000 write=0.000

4. metrics(name:) without the (candidate_id, name, id DESC) index

The state that ships until the index is deployed. These plans are the reason the name: filter returns no values while the flag is disabled. Clone without index_ml_candidate_metrics_on_candidate_id_name_id_desc, run 2219689 (614,560 rows, 25 names). The first page of the name with the most rows (44,360) scans ml_candidate_metrics_pkey backward and filters out 37 M rows. The page at 90% of that name starts the scan at the cursor and is fast. The rarest name (3,156 rows) reads every row of the run through index_ml_candidate_metrics_on_candidate_id and sorts them.

Name with the most rows, first page, first run (Time: 2.502 min, hits: 10161692 (~77.50 GiB), reads: 865713 (~6.60 GiB)), console
 Limit  (cost=1000.59..41315.69 rows=101 width=114) (actual time=150068.345..150096.510 rows=101 loops=1)
   Buffers: shared hit=10161692 read=865713 dirtied=7074 written=7377
   WAL: records=7217 fpi=7217 bytes=55579149
   I/O Timings: read=401404.852 write=117.266
   ->  Gather Merge  (cost=1000.59..3886817.38 rows=9735 width=114) (actual time=150068.343..150096.499 rows=101 loops=1)
         Workers Planned: 2
         Workers Launched: 2
         Buffers: shared hit=10161692 read=865713 dirtied=7074 written=7377
         WAL: records=7217 fpi=7217 bytes=55579149
         I/O Timings: read=401404.852 write=117.266
         ->  Parallel Index Scan Backward using ml_candidate_metrics_pkey on public.ml_candidate_metrics  (cost=0.56..3884693.70 rows=4056 width=114) (actual time=150054.898..150062.614 rows=72 loops=3)
               Filter: ((ml_candidate_metrics.candidate_id = 2219689) AND (ml_candidate_metrics.name = '<name>'::text))
               Rows Removed by Filter: 12400988
               Buffers: shared hit=10161692 read=865713 dirtied=7074 written=7377
               WAL: records=7217 fpi=7217 bytes=55579149
               I/O Timings: read=401404.852 write=117.266
Settings: effective_cache_size = '472585MB', work_mem = '230MB', jit = 'off', random_page_cost = '1.5', seq_page_cost = '4'
Name with the most rows, first page, second run (Time: 2.073 min, hits: 10161559 (~77.50 GiB), reads: 860083 (~6.60 GiB)), console

Same plan as the first run.

Name with the most rows, page at 90% of the history (Time: 37.331 ms, hits: 584, reads: 19), console
 Limit  (cost=1000.59..43017.55 rows=101 width=114) (actual time=15.704..17.339 rows=101 loops=1)
   Buffers: shared hit=584 read=19
   I/O Timings: read=14.572 write=0.000
   ->  Gather Merge  (cost=1000.59..1068481.10 rows=2566 width=114) (actual time=15.703..17.329 rows=101 loops=1)
         Workers Planned: 2
         Workers Launched: 2
         Buffers: shared hit=584 read=19
         I/O Timings: read=14.572 write=0.000
         ->  Parallel Index Scan Backward using ml_candidate_metrics_pkey on public.ml_candidate_metrics  (cost=0.56..1067184.89 rows=1069 width=114) (actual time=2.378..8.511 rows=72 loops=3)
               Index Cond: (ml_candidate_metrics.id < 16690423)
               Filter: ((ml_candidate_metrics.candidate_id = 2219689) AND (ml_candidate_metrics.name = '<name>'::text))
               Rows Removed by Filter: 1644
               Buffers: shared hit=584 read=19
               I/O Timings: read=14.572 write=0.000
Settings: effective_cache_size = '472585MB', work_mem = '230MB', jit = 'off', random_page_cost = '1.5', seq_page_cost = '4'
Rarest name, first page, first run (Time: 46.855 ms, hits: 13089, reads: 0), console
 Limit  (cost=54661.71..54673.49 rows=101 width=114) (actual time=40.917..45.806 rows=101 loops=1)
   Buffers: shared hit=13089
   I/O Timings: read=0.000 write=0.000
   ->  Gather Merge  (cost=54661.71..54994.93 rows=2856 width=114) (actual time=40.916..45.796 rows=101 loops=1)
         Workers Planned: 2
         Workers Launched: 2
         Buffers: shared hit=13089
         I/O Timings: read=0.000 write=0.000
         ->  Sort  (cost=53661.68..53665.25 rows=1428 width=114) (actual time=37.574..37.580 rows=80 loops=3)
               Sort Key: ml_candidate_metrics.id DESC
               Sort Method: top-N heapsort  Memory: 51kB
               Buffers: shared hit=13089
               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=1428 width=114) (actual time=0.111..37.253 rows=1052 loops=3)
                     Index Cond: (ml_candidate_metrics.candidate_id = 2219689)
                     Filter: (ml_candidate_metrics.name = '<name>'::text)
                     Rows Removed by Filter: 203801
                     Buffers: shared hit=13073
                     I/O Timings: read=0.000 write=0.000
Settings: effective_cache_size = '472585MB', work_mem = '230MB', jit = 'off', random_page_cost = '1.5', seq_page_cost = '4'
Rarest name, first page, second run (Time: 1.742 s, hits: 938, reads: 12158 (~95.00 MiB)), console

Same plan as the first run. The second run of the first-page plan ran in between and read 77 GiB, so this run read the heap from disk.

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