-
Steinar H. Gunderson authored
Implement UNION DISTINCT and UNION ALL as iterators. This lifts the iterator execution framework out from the JOIN level and onto the SELECT_LEX_UNIT level, and as such, we need to handle some new cases in iterators that are not directly related to UNION: ZeroRowsIterator and ZeroRowsAggregatedIterator handle the cases where we know beforehand that we will have zero rows from tables. UNION DISTINCT is implemented by extending MaterializeIterator. UNION ALL is handled, wherever possible, with StreamingIterator (works conceptually much like MaterializeIterator, but never actually writes to disk) and AppendIterator (which does what the name suggests; take in rows from multiple sub-iterators sequentually). Combinations of UNION DISTINCT and UNION ALL are handled with a combination of these, depending on the exact circumstances (e.g. sorting). We're usually as efficient as the old executor, and occasionally more (the cases with mixed UNION DISTINCT/UNION ALL can be streamed in more cases than before). Note that we actually regress in the coverage of the new executor in one specific case: If we have a WITH RECURSIVE query, previously the sub-JOINs could be running in the new executor even though the UNION itself wasn't, whereas now, they can't (the entire query will run in the old executor). This will be fixed in a later patch in the series, when we add recursive CTE support. As a side effect of the new handling, we correct certain cases of FOUND_ROWS() on queries that produce a single row (through implicit aggregation) that is filtered away by OFFSET. These used to count as one row for MyISAM and zero for InnoDB; now they consistently are counted as a single row. Finally, we fix an issue where we could optimize away reading of tables even with nondeterministic functions. This exposed a range optimizer issue that has been filed as a separate issue; the test in question (in select.inc) has been rewritten to not show the bug, and should be rewritten back as soon as the bug is fixed. Change-Id: I94195c308b22622970502df070ede392e991a2cb
Steinar H. Gunderson authoredImplement UNION DISTINCT and UNION ALL as iterators. This lifts the iterator execution framework out from the JOIN level and onto the SELECT_LEX_UNIT level, and as such, we need to handle some new cases in iterators that are not directly related to UNION: ZeroRowsIterator and ZeroRowsAggregatedIterator handle the cases where we know beforehand that we will have zero rows from tables. UNION DISTINCT is implemented by extending MaterializeIterator. UNION ALL is handled, wherever possible, with StreamingIterator (works conceptually much like MaterializeIterator, but never actually writes to disk) and AppendIterator (which does what the name suggests; take in rows from multiple sub-iterators sequentually). Combinations of UNION DISTINCT and UNION ALL are handled with a combination of these, depending on the exact circumstances (e.g. sorting). We're usually as efficient as the old executor, and occasionally more (the cases with mixed UNION DISTINCT/UNION ALL can be streamed in more cases than before). Note that we actually regress in the coverage of the new executor in one specific case: If we have a WITH RECURSIVE query, previously the sub-JOINs could be running in the new executor even though the UNION itself wasn't, whereas now, they can't (the entire query will run in the old executor). This will be fixed in a later patch in the series, when we add recursive CTE support. As a side effect of the new handling, we correct certain cases of FOUND_ROWS() on queries that produce a single row (through implicit aggregation) that is filtered away by OFFSET. These used to count as one row for MyISAM and zero for InnoDB; now they consistently are counted as a single row. Finally, we fix an issue where we could optimize away reading of tables even with nondeterministic functions. This exposed a range optimizer issue that has been filed as a separate issue; the test in question (in select.inc) has been rewritten to not show the bug, and should be rewritten back as soon as the bug is fixed. Change-Id: I94195c308b22622970502df070ede392e991a2cb
Loading