Skip to content

Commit

Permalink
MDEV-29284 ANALYZE doesn't work with pushed derived tables
Browse files Browse the repository at this point in the history
There was no actual execution of the SQL of a pushed derived table,
which caused "r_rows" to be always displayed as 0 and "r_total_time_ms"
to show inaccurate numbers.
This commit makes a derived table SQL to be executed by the storage
engine, so the server is able to calculate the number of rows returned
and measure the execution time more accurately
  • Loading branch information
Olernov committed Jul 7, 2023
1 parent 1bfd3cc commit 94a8921
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
4 changes: 2 additions & 2 deletions mysql-test/suite/federated/federatedx_create_handlers.result
Expand Up @@ -190,7 +190,7 @@ FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t
WHERE federated.t3.name=t.name;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 7 7.00 100.00 100.00
1 PRIMARY <derived2> ref key0 key0 18 federated.t3.name 2 0.00 100.00 100.00
1 PRIMARY <derived2> ref key0 key0 18 federated.t3.name 2 1.00 100.00 100.00
2 PUSHED DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
SELECT *
FROM federated.t3, (SELECT t1.name FROM federated.t1
Expand Down Expand Up @@ -241,7 +241,7 @@ ANALYZE
"ref": ["federated.t3.name"],
"r_loops": 7,
"rows": 2,
"r_rows": 0,
"r_rows": 0.1429,
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100,
Expand Down
7 changes: 0 additions & 7 deletions sql/derived_handler.cc
Expand Up @@ -40,7 +40,6 @@
Pushdown_derived::Pushdown_derived(TABLE_LIST *tbl, derived_handler *h)
: derived(tbl), handler(h)
{
is_analyze= handler->thd->lex->analyze_stmt;
}


Expand All @@ -57,12 +56,6 @@ 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 (unlikely(thd->check_killed()))
Expand Down
2 changes: 0 additions & 2 deletions sql/sql_select.h
Expand Up @@ -2545,8 +2545,6 @@ class derived_handler;

class Pushdown_derived: public Sql_alloc
{
private:
bool is_analyze;
public:
TABLE_LIST *derived;
derived_handler *handler;
Expand Down

0 comments on commit 94a8921

Please sign in to comment.