-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-36523: Load basic stats from trace into optimizer #4255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 12.1-MDEV-36511-dump-basic-statistics
Are you sure you want to change the base?
MDEV-36523: Load basic stats from trace into optimizer #4255
Conversation
4c45f29 to
d9d1fa9
Compare
b959816 to
822fd6e
Compare
class Read_named_member
{
public:
const char *name;
Read_value &&value;
const bool &&is_optional;Q1: Why is "is_optional" rvalue reference? |
|
Do we need two functions: |
|
Please also go through |
35c3f91 to
fcf83f4
Compare
changed to use ha_scan_time() |
removed optimizer_replay_context from being the mysqld command line argument |
sure, done. |
sure, picked the third variant. |
sure, done. |
treating is_optional as a regular bool field, and yes it is used. |
Actually, changed the names for better readability now. Yes, we require both |
yes, changed them. |
5437094 to
f0eb1e5
Compare
27f7d9c to
35208ee
Compare
35208ee to
ccbb126
Compare
ccbb126 to
7aa9da7
Compare
f0eb1e5 to
bbf1393
Compare
This task loads the stats of the tables that are used in a query, from the trace into the optimizer. This feature is controlled by optimizer_replay_context, and points to an user defined variable name, that has the context information. The stats such as num_of_records present in the table, indexes if present, their names, along with the average number of records_per_key with in each index, cost of reading an index are loaded from the trace. Additionally, stats from range analysis i.e. ranges, and the corresponding number of records, along with their costs are also loaded from the trace. The trace context which is in JSON format is firstly set into the user defined session variable, and this variable name is set to optimizer_replay_context system variable. Later, when a user issues a query, the contents of the json context is parsed and an in memory representation is built using the class Optimizer_context_replay. 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. Two new warning/error messages are introduced: ER_JSON_OPTIMIZER_REPLAY_CONTEXT_PARSE_FAILED, and ER_JSON_OPTIMIZER_REPLAY_CONTEXT_MATCH_FAILED
7aa9da7 to
3592227
Compare

This task loads the stats of the tables that are used in a query,
from the trace into the optimizer. This feature is controlled
by optimizer_replay_context, and points to an user defined variable name,
that has the context information.
The stats such as num_of_records present in the table, indexes if present,
their names, along with the average number of records_per_key
with in each index, cost of reading an index are loaded from the trace.
Additionally, stats from range analysis i.e. ranges, and the
corresponding number of records, along with their costs are also
loaded from the trace.
The trace context which is in JSON format is firstly set into the
user defined session variable, and this variable name is set to
optimizer_replay_context system variable.
Later, when a user issues a query, the contents of the json context is
parsed and an in memory representation is built using the class
Optimizer_context_replay. 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.
Two new warning/error messages are introduced:
ER_JSON_OPTIMIZER_REPLAY_CONTEXT_PARSE_FAILED, and
ER_JSON_OPTIMIZER_REPLAY_CONTEXT_MATCH_FAILED