-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-36511 dump basic statistics to the trace #4087
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: main
Are you sure you want to change the base?
Conversation
48443ea to
45acb67
Compare
|
|
||
| if (unlikely(thd->trace_started())) | ||
| trace_ranges(&trace_range, param, idx, key, key_part); | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move almost all of this code into a function which should be in `opt_trace_ddl_info.*' (we'll eventually rename that file to reflect that optimizer context capture code is there).
We're reusing trace_ranges to produce the list of ranges. This is ok. I think for better isolation, let trace_ranges just accept a callback (or lambda function) which it will use to report ranges.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure. will do in next development sprint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved most of the changes to opt_trace_ddl_info.cc, and some of them to trace_ranges()
| return false; | ||
| } | ||
|
|
||
| static void dump_index_range_stats_to_trace(THD *thd, uchar *tbl_name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this function into opt_trace_ddl_info.cc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is already in opt_trace_ddl_info.cc
sql/opt_trace_ddl_info.h
Outdated
| bool store_table_definitions_in_trace(THD *thd); | ||
| bool store_tables_context_in_trace(THD *thd); | ||
|
|
||
| struct trace_range_context{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this into opt_trace_ddl_info.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is already in opt_trace_ddl_info.h
sql/sql_class.h
Outdated
| HASH ull_hash; | ||
| /* Hash of used sequences (for PREVIOUS value) */ | ||
| HASH sequences; | ||
| /* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a pointer.
I would expect it to be a pointer to some structure with methods. Something like
Optimizer_context_recorder *opt_context_recorder;
opt_range code should invoke a function to lazily create the recorder, if necessary.
Then, store_tables_context_in_trace() should dump the data from the context recorder.
The code in opt_trace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure. will do in next development sprint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made the changes.
8740969 to
a71242f
Compare
deb8e78 to
db937cc
Compare
a71242f to
52996cd
Compare
|
Please checkout review input here: |
|
What is the point of this allocation in opt_range.cc : |
|
What will be recorded by your patch if one runs this: select *
from t1 at TBL, t1 as TBL2
where TBL1.key1 < 'foo' and
TBL2.key2 < 'bar'? |
52996cd to
b434979
Compare
sure. Incorporated the changes. |
new allocation is not required, so removed the memory allocation code. However, we require range_list so as to store all the ranges that were created in this method, before it can be passed to recorder. |
|
67397e8 to
97fd0f2
Compare
|
@bsrikanth-mariadb , please check this : 9438e15 : Any comments? |
|
Next question: can we move implementation details from opt_trace_ddl_info.h to opt_trace_ddl_info.cc ? |
97fd0f2 to
491ded1
Compare
sure. done |
yes, liked it. incorporated the changes. |
491ded1 to
c14aad7
Compare
c14aad7 to
5437094
Compare
5437094 to
f0eb1e5
Compare
This feature stores the basic stats of the base tables that are used in a query, to the optimizer trace. 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 dumped to the trace. Additionally, stats from range analysis of the queries are also dumped into the trace The approach taken here is to extend the existing function store_tables_context_in_trace() and add new dump_table_stats_to_trace() to opt_trace_ddl_info.cc. For storing the range analysis stats into the trace, they are first recorded in the hash defined in Optimizer_Stats_Context_Recorder, and is used later while dumping the stats into the trace from dump_table_stats_to_trace(). Several new tests are also added to opt_trace_store_stats.test
f0eb1e5 to
bbf1393
Compare
Pull request created in: https://jira.mariadb.org/browse/MDEV-36511