mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Derived tables and union can now create distinct keys
The idea is that instead of marking all select_lex's with DISTINCT, we only mark those that really need distinct result. Benefits of this change: - Temporary tables used with derived tables, UNION, IN are now smaller as duplicates are removed already on the insert phase. - The optimizer can now produce better plans with EQ_REF. This can be seen from the tests where several queries does not anymore materialize derived tables twice. - Queries affected by 'in_predicate_conversion_threshold' where large IN lists are converted to sub query produces better plans. Other things: - Removed on duplicate call to sel->init_select() in LEX::add_primary_to_query_expression_body() - I moved the testing of tab->table->pos_in_table_list->is_materialized_derived() in join_read_const_table() to the caller as it caused problems for derived tables that could be proven to be const tables. This also is likely to fix some bugs as if join_read_const_table() was aborted, the table was left marked as JT_CONST, which cannot be good. I added an ASSERT there for now that can be removed when the code has been properly tested.
This commit is contained in:
@ -1575,6 +1575,9 @@ values ((values (4)), (select 5)), ((select 2), (values (8)));
|
||||
|
||||
values ((values (1) union values (1)));
|
||||
|
||||
--error ER_SUBQUERY_NO_1_ROW
|
||||
values ((values (1) union all values (1)));
|
||||
|
||||
values ((values (1) union values (1) union values (1)));
|
||||
|
||||
values ((values ((values (4)))));
|
||||
|
Reference in New Issue
Block a user