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:
analyze format=json select * from federated.t1 where a<3;
ANALYZE
{
"query_block": {
"select_id": 1,
"table": {
"message": "Pushed select"
}
}
}
Oleg Smirnov
added a comment - 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:
analyze format=json select * from federated.t1 where a<3;
ANALYZE
{
"query_block": {
"select_id": 1,
"table": {
"message": "Pushed select"
}
}
}
The cause of this is that the server does not actually loop through the rows returned from the storage engine when doing ANALYZE:
derived_handler.cc
int Pushdown_derived::execute()
{
...
if ((err= handler->init_scan()))
goto error;
if (is_analyze)
{
handler->end_scan();
DBUG_RETURN(0);
}
while (!(err= handler->next_row()))
{
...
}
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.
Removing
if (is_analyze)
{
handler->end_scan();
DBUG_RETURN(0);
}
makes "r_rows" show the actual data. It is interesting what was the reasoning behind such a limitation for ANALYZE. igor, can you comment?
Oleg Smirnov
added a comment - The cause of this is that the server does not actually loop through the rows returned from the storage engine when doing ANALYZE:
derived_handler.cc
int Pushdown_derived::execute()
{
...
if ((err= handler->init_scan()))
goto error;
if (is_analyze)
{
handler->end_scan();
DBUG_RETURN(0);
}
while (!(err= handler->next_row()))
{
...
}
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.
Removing
if (is_analyze)
{
handler->end_scan();
DBUG_RETURN(0);
}
makes "r_rows" show the actual data. It is interesting what was the reasoning behind such a limitation for ANALYZE. igor , can you comment?
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.
Sergei Petrunia
added a comment - 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.
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.
Oleg Smirnov
added a comment - 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.
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:
analyze format=json select * from federated.t1 where a<3;
ANALYZE
{
"query_block": {
"select_id": 1,
"table": {
"message": "Pushed select"
}
}
}