1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

Bug #30377: EXPLAIN loses last_query_cost when used with UNION

Currently the Last_query_cost session status variable shows
only the cost of a single flat subselect. For complex queries
(with subselects or unions etc) Last_query_cost is not valid
as it was showing the cost for the last optimized subselect.
Fixed by reseting to zero Last_query_cost when the complete
cost of the query cannot be determined.
Last_query_cost will be non-zero only for single flat queries.
This commit is contained in:
gkodinov/kgeorge@magare.gmz
2007-08-28 18:51:03 +03:00
parent 4446fd4b0d
commit cfaa0983c8
4 changed files with 108 additions and 2 deletions

View File

@ -4369,9 +4369,13 @@ choose_plan(JOIN *join, table_map join_tables)
/*
Store the cost of this query into a user variable
Don't update last_query_cost for 'show status' command
Don't update last_query_cost for 'show status' command.
Don't update last_query_cost for statements that are not "flat joins" :
i.e. they have subqueries, unions or call stored procedures.
TODO: calculate a correct cost for a query with subqueries and UNIONs.
*/
if (join->thd->lex->orig_sql_command != SQLCOM_SHOW_STATUS)
if (join->thd->lex->orig_sql_command != SQLCOM_SHOW_STATUS &&
join->thd->lex->is_single_level_stmt())
join->thd->status_var.last_query_cost= join->best_read;
DBUG_RETURN(FALSE);
}