mariadb/sql/opt_group_by_cardinality.h
Rex Johnston 8d08350dd3 MDEV-36321 keys generated on derived tables produce wrong out_rows estimates
record per key statistics on keys generated for derived tables are missing,
causing a fallback to the usage of MATCHING_ROWS_IN_OTHER_TABLE in
best_access_path().
This can grossly overestimate the number of rows expected during a join
and cause a bad join order.  This patch tries to infer a few simple
things about the derived table, like when the key being created matches
the group by list inside (if any) inside the derived table.

Approved by Sergei Petrunia (sergey@mariadb.com)
Tested by Lena Startseva (lena.startseva@mariadb.com)
2025-10-16 09:31:56 +12:00

11 lines
316 B
C

#ifndef OPT_GROUP_BY_CARDINALITY
#define OPT_GROUP_BY_CARDINALITY
double estimate_post_group_cardinality(JOIN *join, double join_output_card);
void infer_derived_key_statistics(st_select_lex_unit* derived,
KEY *keyinfo,
uint key_parts);
#endif