mariadb/mysql-test/suite/sys_vars
bsrikanth-mariadb 120dc073c2 MDEV-36523: Load basic stats from trace into optimizer
This task loads the stats of the tables that are used in a query, from the trace into the optimizer.
This feature is also controlled by optimizer_record_context, and is not enabled by default. The stats
such as num_of_records present in the table, indexes if present then their names, along with the average number of records_per_key with in each index are loaded from the trace. Additionally, stats from range analysis i.e. ranges, and the corresponding number of records are also loaded from the trace.

The trace context which is in JSON format is firstly set into the session variable optimizer_trace_stored_context. Later, when a user issues a query, the contents of optimizer_trace_stored_context variable is parsed and an in memory representation is build using the class Optimizer_Trace_Stored_Context_Extractor. This class is then used by the optimizer to update and save original values of the tables, indexes, and range stats in the methods "set_statistics_for_table()" of sql_statistics.cc, and "check_quick_select()" of opt_range.cc. After the query gets finished, the statistics that were updated in the optimizer are restored back to the saved original values.

The entry point for parsing the json structure is in "mysql_execute_command()" of sql_parse.cc, and similarly exit point i.e. to restore the saved stats of the optimizer is at the end of the same method.
2025-09-01 07:50:54 +05:30
..
inc Merge branch '11.4' into 11.8 2025-06-18 07:43:24 +02:00
r MDEV-36523: Load basic stats from trace into optimizer 2025-09-01 07:50:54 +05:30
t cleanup: disconnect before DROP USER 2025-07-16 09:14:33 +07:00
disabled.def MDEV-21452: Replace ib_mutex_t with mysql_mutex_t 2020-12-15 17:56:18 +02:00