MariaDB-server/mysql-test/include/execute_with_statistics.inc

31 lines
771 B
PHP
Raw Permalink Normal View History

2022-06-02 19:47:23 +03:00
# include/execute_with_statistics.inc
#
# SUMMARY
#
2025-04-07 20:13:58 +03:00
# Explain and execute the select statement in $query.
2022-06-02 19:47:23 +03:00
# Then report 'Last_query_cost' estimate from the query
# optimizer and total number of 'Handler_read%' when the
# query was executed.
2025-04-07 20:13:58 +03:00
# Intended usage is to verify that there are no regressions
# in either calculated or actual cost for $query.
2022-06-02 19:47:23 +03:00
#
# USAGE
#
# let $query= <select statement>;
# --source include/execute_with_statistics.inc
#
# EXAMPLE
# t/greedy_optimizer.test
#
eval EXPLAIN $query;
SHOW STATUS LIKE 'Last_query_cost';
FLUSH STATUS;
eval $query;
--disable_warnings
SELECT SUM(variable_value) AS Total_handler_reads
FROM information_schema.session_status
WHERE variable_name LIKE 'Handler_read%';
--enable_warnings