Bug #68840 | question about new code in make_join_statistics | ||
---|---|---|---|
Submitted: | 2 Apr 2013 20:21 | Modified: | 3 Apr 2013 20:33 |
Reporter: | Mark Callaghan | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S5 (Performance) |
Version: | 5.6.10 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[2 Apr 2013 20:21]
Mark Callaghan
[3 Apr 2013 6:05]
Roy Lyseng
Hi Mark, it is not new code, just refactoring of old code that has existed for a long time. The achievement here was to separate out the code that deals with const tables, rather than having it as part of a more general loop. The refactoring was done as part of semi-join development, which added to the complexity of this part of the function. We also wanted to separate dependency calculations from const table calculations, because dependency calculations are generic for a query and can be done up front, whereas const table calculations has to be redone for every execution. This argument obviously relates to prepared statements only. I guess the possibly good thing for you is that you can #ifdef away this code block entirely.
[3 Apr 2013 13:06]
Mark Callaghan
I noticed this in the context of running sysbench. The queries are of the form PK = $value. Whether or not HA_STATS_RECORDS_IS_EXACT is set, the table returns at most 1 row. Why can't the optimization be used in this case?
[3 Apr 2013 19:58]
Roy Lyseng
The loop you highlighted only deals with tables that have exactly zero or one rows. The loop after that reads those rows directly from the table. There is another loop, starting at label const_table_extraction_done that looks at predicates and identifies tables that can use ref or eq_ref access. When an equality predicate can use a unique index, such as pk=<value>, the access method is changed to CONST and the row is read immediately. Thus, the greedy optimizer will loop over zero tables and JOIN::exec() becomes almost a no-op for this simple query (it just has to pass the already retrieved column values to the client). We can probably do more to short-cut the execution patch for such simple queries, though.
[3 Apr 2013 20:31]
Mark Callaghan
Thanks for the prompt responses. While there is more overhead from the optimizer in 5.6, this bug is bogus. Please close it.