[MDEV-29284] ANALYZE doesn't work with pushed derived tables Created: 2022-08-10 Updated: 2023-09-11 Resolved: 2023-07-07 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - Federated |
| Affects Version/s: | 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10 |
| Fix Version/s: | 10.4.31, 10.5.22, 10.6.15, 10.9.8, 10.10.6, 10.11.5, 11.0.3, 11.1.2, 11.2.1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sergei Petrunia | Assignee: | Oleg Smirnov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
(I tried on 10.6 and 10.10 but perhaps earlier versions are affected as well) Put this into mysql-test/suite/federated/a1.test :
and run. At the end of output see:
Note the {{ "r_rows": 0}}. This is because pushdown code doesn't handle ANALYZE correctly. |
| Comments |
| Comment by Oleg Smirnov [ 2023-07-03 ] | |||||||||||||||||||||||||
|
So what is the goal of this task - to display correct "r_rows" or to remove "r_rows" line for pushed down derived tables? For information, there is almost no analyze data for pushed SELECTs:
| |||||||||||||||||||||||||
| Comment by Oleg Smirnov [ 2023-07-04 ] | |||||||||||||||||||||||||
|
The cause of this is that the server does not actually loop through the rows returned from the storage engine when doing ANALYZE:
If just does init_scan() and then end_scan() without looping through next_row() results. The same approach is observed at select_handler.cc for pushed SELECTs.
makes "r_rows" show the actual data. It is interesting what was the reasoning behind such a limitation for ANALYZE. igor, can you comment? | |||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-07-04 ] | |||||||||||||||||||||||||
|
ANALYZE should execute the query. That means executing pushed down derived tables. This should be easy to implement. It might be harder to handle ANALYZE in the select handler... ha_federated passes the query text to the backend. However, the backend then will produce ANALYZE output (either tabular or JSON). I'm not sure if the frontend is prepared to deal with this). In any case, it seems obvious to me that for pushed derived tables, ANALYZE should read the rows from the backend. | |||||||||||||||||||||||||
| Comment by Oleg Smirnov [ 2023-07-05 ] | |||||||||||||||||||||||||
|
psergei, please review bb-10.4-mdev-29284. I didn't add a new test case since there is one already in federated.federatedx_create_handlers covering this. | |||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-07-06 ] | |||||||||||||||||||||||||
|
oleg.smirnov, please apply the below patch. Ok to push after it is applied.
| |||||||||||||||||||||||||
| Comment by Oleg Smirnov [ 2023-07-07 ] | |||||||||||||||||||||||||
|
Pushed to 10.4 |