pingcap / pingcap/docs

Question: Is "genetic search algorithm" the correct description for Index Advisor?

Open
#23,379 1 comment 0 reactions 1 assignee View on GitHub

@qw4990 is already working on this.

Since Jul 30, 2026.

Dominant language
Python
Stars
617
Forks
724
Avg merge
2d 10h
Merged PRs (30d)
223

Description

Question

Documentation page
https://docs.pingcap.com/tidb/stable/index-advisor/#index-advisor

Current text

The Index Advisor analyzes queries to identify indexable columns from clauses such as WHERE, GROUP BY, and ORDER BY. Then, it generates index candidates and estimates their performance benefits using hypothetical indexes. TiDB uses a genetic search algorithm to select the optimal set of indexes starting with single-column indexes and iteratively exploring multi-column indexes, leveraging a "What-If" analysis to evaluate potential indexes based on their impact on optimizer plan costs. The advisor recommends indexes when they reduce the overall cost compared to executing queries without them.

Question

I'd like to ask about the phrase "TiDB uses a genetic search algorithm" in this description.

Looking at the source code comment in pkg/planner/indexadvisor/algorithm.go:

https://github.com/pingcap/tidb/blob/release-8.5-20260724-v8.5.7/pkg/planner/indexadvisor/algorithm.go#L26-L33

This algorithm resembles the index selection algorithm published in 1997 by Chaudhuri
and Narasayya. Details can be found in the original paper:
Surajit Chaudhuri, Vivek R. Narasayya: An Efficient Cost-Driven Index Selection
Tool for Microsoft Query Server. VLDB 1997: 146-155
This implementation is the Golang version of
https://github.com/hyrise/index_selection_evaluation/blob/refactoring/selection/algorithms/auto_admin_algorithm.py.

The implementation (calculateBestIndexes, enumerateNaive, enumerateGreedy, selectIndexCandidates) appears to enumerate small candidate sets exhaustively and extend larger ones greedily, guided by cost estimates from What-If analysis — which looks like the classic AutoAdmin algorithm (Chaudhuri & Narasayya, VLDB 1997) rather than a genetic algorithm in the usual sense (population, crossover, mutation, fitness-based selection across generations).

Could someone help clarify:

  1. Is "genetic search algorithm" intended as a general/informal way of describing the iterative candidate-generation process, or does it refer to an actual genetic-algorithm technique used somewhere in the implementation?
  2. If it's the former, would it make sense to update the wording to avoid confusion with the formal meaning of "genetic algorithm"?

Happy to help with a doc PR if that would be useful.

References

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.