[MDEV-31577] Make ANALYZE FORMAT=JSON print innodb stats Created: 2023-06-29 Updated: 2023-09-29 Resolved: 2023-07-22 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer, Storage Engine - InnoDB |
| Fix Version/s: | 10.8.8, 10.6.15, 10.9.8, 10.10.6, 10.11.5, 11.0.3, 11.1.2, 11.2.1 |
| Type: | Task | Priority: | Major |
| Reporter: | Sergei Petrunia | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | analyze-stmt | ||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
It would be nice to include it into ANALYZE FORMAT=JSON output, too. User interface: Extra info is printed in ANALYZE FORMAT=JSON output. It is printed on per-table basis. table.r_engine_stats will is an object with member counters. In current patch, it looks like this:
Only non-zero members are printed. mysql-test/include/analyze-format.inc is adjusted to mask the entire contents of r_engine_stats. |
| Comments |
| Comment by Sergei Petrunia [ 2023-06-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
bb-10.11-mdev31577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-06-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Points about the patch:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2023-06-30 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I agree that JSON_EXT is a wrong value and FORMAT is a wrong place. Why should it be conditional at all? It's JSON. In tabular format you cannot easily add new values and columns, it might break existing applications. But JSON doesn't have a fixed schema and is almost infinitely extendable. Applications simply ignore keys they aren't interested in. So I'd suggest to print new information in FORMAT=JSON and not make it conditional | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-07-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Note that PostreSQL has similar behavior: their EXPLAIN ANALYZE doesn't print number of pages fetched by default, one needs to use "EXPLAIN BUFFERS" syntax to get it. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-07-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I agree that using the FORMAT field to control what is printed doesnt' look like a good idea. But should engine stats always be printed or one needs some syntax to indicate they want them? Arguments for printing always:
Arguments for printing only when requested:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-07-04 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Takeaways from discussion with Monty:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-07-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
New patch:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleg Smirnov [ 2023-07-08 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
1. Are you sure "analyze_format_json_ext.test" is a good name for the test since it has been decided not to introduce new FORMAT specifier (JSON_EXT)? The name of the test seems to be confusing. 2. The only info I have managed to see in the "r_engine_stats" section is "pages_accessed", and it's only available for SELECTs. For an INSERT the section is empty:
and for an UPDATE it is missing:
The first question is why "pages_updated", "pages_read_count", "pages_read_time_ms", "old_rows_read" are not displayed, and the second is why there is no "r_engine_stats" for INSERTs and UPDATEs? | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-07-20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
oleg.smirnov, thanks for the input. Re INSERT ... SELECT: currently, EXPLAIN (and ANALYZE) output only describes the SELECT part. In the statement you've provided, the SELECT part uses sequence storage engine so it doesn't show r_engine_stats. Should EXPLAIN or ANALYZE output show something about the table we're inserting to? I don't see what EXPLAIN would show. ANALYZE FORMAT=JSON could show the time spent writing to the table, and now with As for UPDATEs/DELETEs, indeed it is an omission in the patch. The engine statistics are counted but not displayed. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-08-22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
The patch for this MDEV will work with any Storage Engine that provides the statistics data. However, the patch for
So, currently one can get the stats from [partitioned] innodb. Other storage engines can add support for this. |