Remove the ml_candidate_metric_order_lateral feature flag

What does this MR do and why?

Removes the ml_candidate_metric_order_lateral feature flag. Candidate lists ordered by a metric (the MLflow runs/search API and the experiment page, HTML and CSV) look up the latest metric value of each candidate with a LATERAL join, instead of computing the latest value of the metric for every candidate in the table. Experiments with more than 50,000 candidates keep the DISTINCT ON query, as they did with the flag on.

The flag has been at 100% on GitLab.com since 2026-10-29.

Design notes
  • Only the flag check goes away. Projects::Ml::CandidateFinder#lateral_metric_order? keeps the candidate limit (LATERAL_METRIC_ORDER_MAX_CANDIDATES, Ml::Experiment#more_candidates_than?), so the DISTINCT ON branch of Ml::Candidate.order_by_metric and its lateral: keyword stay: experiments above the limit still use them. No query changes for any experiment compared with the flag on.
  • The limit, the DISTINCT ON branch and the new ml_candidate_metrics (candidate_id, name, id DESC) index are the follow-up #635116 (closed). That issue does not need the flag. The index must not exist while the DISTINCT ON query still runs, so the index and the removal of the limit go together in that MR.
  • Spec changes:
    • spec/finders/projects/ml/candidate_finder_spec.rb: the keyset pagination examples for the DISTINCT ON query now reach it through the candidate limit (stub_const) instead of the disabled flag. The second commit stubs that limit to 1, below the candidate count, and checks that the query has no LATERAL. The metric ordering join examples already cover both sides of the limit, so the flag-disabled example is gone.
    • spec/requests/api/ml/mlflow/runs_spec.rb and spec/requests/projects/ml/experiments_controller_spec.rb: the flag-disabled contexts are gone, and the shared examples that ran the same checks in both flag states are inline again.
  • The mlflow_search_order_by_list flag uses the same search code and stays.

References

Rollback: revert this MR.

Screenshots or screen recordings

No UI change.

How to set up and validate locally

  1. Create an experiment with a few candidates that log a metric, for example with the MLflow client against http://gdk.test:3000/api/v4/projects/<id>/ml/mlflow, logging auc with a different value on each run.
  2. Visit http://gdk.test:3000/<namespace>/<project>/-/ml/experiments/<iid>.
  3. Sort the candidate list by the auc metric, descending and ascending, and page through it.
  4. Expect: the candidates appear in metric order, candidates without the metric are not listed, and no candidate appears twice across pages.

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