Commit graph

44 commits

Author SHA1 Message Date
Sergei Golubchik
1185420da0 5.3 merge 2012-05-21 20:54:41 +02:00
Sergey Petrunya
4dff59a31b Merge 5.2->5.3 2012-05-12 12:27:26 +04:00
Sergey Petrunya
e1b6e1b899 Merge 5.2->5.3 2012-05-12 12:12:35 +04:00
Sergey Petrunya
97ae1682f1 BUG#997747: Assertion `join->best_read < ((double)1.79..5e+308L)' failed
in greedy_search with LEFT JOINs and unique keys
- Backport the fix for BUG#806524 from MariaDB 5.3
2012-05-12 11:53:14 +04:00
Sergey Petrunya
0099593562 BUG#919878: Assertion `!eliminated_tables...
- In MySQL 5.5, print_join() was re-worked to print "FROM dual" when all
  tables are constant. This change didn't work together with table 
  elimination.
2012-02-21 01:08:22 +04:00
Igor Babaev
f5dac20f38 Made the optimizer switch flags 'outer_join_with_cache', 'semijoin_with_cache'
set to 'on' by default.
2011-12-15 00:21:15 -08:00
Igor Babaev
af3d1da31d Made the optimizer switch for index condition pushdown set to 'on' by default. 2011-11-21 05:16:16 -08:00
Sergei Golubchik
557f0d3ad0 5.2->5.3 merge 2011-11-12 18:08:12 +01:00
Sergey Petrunya
f2b6f4e3df BUG#884184: Wrong result with RIGHT JOIN + derived_merge
- Make eliminate_tables_for_list() take into account that it is not possible
  to eliminate a table if it is used in the upper-side ON expressions. Example:

    xxx JOIN (t1 LEFT JOIN t2 ON cond ) ON func(t2.columns)

  Here it would eliminate t2 which is not possible because of use of t2.columns.
2011-11-01 12:36:43 +04:00
Igor Babaev
715dc5f99d Fixed a cost estimation bug introduced into in the function best_access_path
of the 5.3 code line after a merge with 5.2 on 2010-10-28
in order not to allow the cost to access a joined table to be equal
to 0 ever.

Expanded data sets for many test cases to get the same execution plans
as before.
2011-09-30 18:55:02 -07:00
Sergey Petrunya
1492de8563 Set the default to be mrr=off,mrr_sort_keys=off:
- Set the default
- Adjust the testcases so that 'new' tests are run with optimizations turned on.
- Pull out relevant tests from "irrelevant" tests and run them with optimizations on.
- Run range.test and innodb.test with both mrr=on and mrr=off
2011-07-08 18:46:47 +04:00
Igor Babaev
89cf840cd9 Merge 2011-05-20 12:47:39 -07:00
Igor Babaev
704f97035f Merged the code of MWL#106 into 5.3
Resolved all conflicts, bad merges and fixed a few minor bugs in the code.
Commented out the queries from multi_update, view, subselect_sj, func_str,
derived_view, view_grant that failed either with crashes in ps-protocol or
with wrong results.
The failures are clear indications of some bugs in the code and these bugs
are to be fixed.
2011-05-16 22:39:43 -07:00
Sergey Petrunya
997445bc8e Make EXPLAIN better at displaying MRR/BKA:
- "Using MRR" is no longer shown with range access.
- Instead, both range and BKA accesses will show one of the following:
  = "Rowid-ordered scan"
  = "Key-ordered scan"
  = "Key-ordered Rowid-ordered scan"
depending on whether DS-MRR implementation will do scan keys in order, rowids in order,
or both.
- The patch also introduces a way for other storage engines/MRR implementations to
  pass information to EXPLAIN output about the properties of employed MRR scans.
2011-04-02 14:04:45 +04:00
Michael Widenius
bda130e6b3 Updated test results for 5.3
Changed handler.inc to make test row order independent

mysql-test/r/table_elim.result:
  Updated test results for 5.3
mysql-test/suite/handler/aria.result:
  Updated result
mysql-test/suite/handler/handler.inc:
  Changed handler.inc to make test row order independent
mysql-test/suite/handler/heap.result:
  Updated result
mysql-test/suite/handler/innodb.result:
  Updated result
mysql-test/suite/handler/myisam.result:
  Updated result
2011-01-13 02:59:11 +02:00
Michael Widenius
1fbcaf2e61 Merge with 5.2 2011-01-12 17:50:29 +02:00
Sergey Petrunya
ef62320957 BUG#675118: Elimination of a table results in an invalid execution plan
- Fix for MySQL BUG#52357 added NESTED_JOIN::is_fully_covered() which would 
  not take into account that MariaDB's table elimination could eliminate tables
  from join plan (and so, from join nest).
  Fixed the check in the function to compare post-table-elimination numbers.
2011-01-11 12:42:16 +02:00
Igor Babaev
7f52af655a Merge. 2010-12-10 23:23:34 -08:00
Igor Babaev
4f75a8254a Merge 5.3-mwl128 -> 5.3 2010-10-27 16:31:22 -07:00
Sergey Petrunya
72dd7575cd Merge 5.2->5.3
- Re-commit Monty's merge, partially fixed by Igor and SergeyP, 
  but still broken
2010-10-10 17:18:11 +03:00
Igor Babaev
21b1b5f040 Fixed bug #52636.
Applied the fix for bug #47217 from the mysql-6.0 codebase.
The patch adds not null predicates generated for the left parts
of the equality predicates used for ref accesses. This is done
for such predicates both in where conditions and on conditions.
For the where conditions the not null predicates were generated
but in 5.0/5.1 they actually never were used due to some lame
merge from 4.1 to 5.0. The fix for bug #47217 made these 
predicates to be used in the condition pushed to the tables.
Yet only this patch generates not null predicates for equality
predicated from on conditions of outer joins.
This patch introduces a performance regression that can be
observed on a test case from null_key.test. The regression
will disappear after the fix for bug #57024 from mariadb-5.1
is pulled into mariadb-5.3.
The patch contains many changes in the outputs of the EXPLAIN 
commands since generated not null predicates are considered as
parts of the conditions pushed to join tables and may add
'Usingwhere' in some rows of EXPLAINs where there used
to be no such comments.
2010-09-28 12:39:33 -07:00
Igor Babaev
b969df8bbd Merge of the mwl106 tree into the latest 5.3 tree.
Resolved conflicts. Adjusted some test results
2010-09-23 08:10:53 -07:00
Igor Babaev
577b7345c7 Fixed bug #49600.
The problem could be demonstrated with an outer join of two single-row
tables where the values of the join attributes were null. Any query
with such a join could return a wrong result set if the where
condition of the query was not empty. For queries with empty
where conditions the result sets were correct.
This was the consequence of two bugs in the code:
 - Item_equal objects for on conditions of outer joins were
   not built if the processed query had no where condition
 - the check for null values in the code that evaluated constant 
   Item_equal objects was incorrect.
Fixed both above problems.
Added a test case for the bug and adjusted results for some other
test cases.
2010-09-11 08:20:35 -07:00
Sergey Petrunya
27f9fc063c MariaDB 5.2 -> MariaDB 5.3 merge 2010-06-26 14:05:41 +04:00
Igor Babaev
709a0a1310 MWL#106: Backport optimizations for derived tables and views.
The main consolidated patch.
2010-05-26 13:18:18 -07:00
unknown
b1e00b6be8 Merge MySQL 5.1.46 into MariaDB.
Still two test failures to be solved: main.myisam and main.subselect.
2010-04-28 14:52:24 +02:00
Sergey Petrunya
7df026676b Merge MariaDB-5.2 -> MariaDB 5.3 2010-03-20 15:01:47 +03:00
Sergey Petrunya
81424b5bda LPBUG#524025 Running RQG outer_join test leads to crash
Save no-records constant tables in JOIN::const_table_map before we invoke
eliminate_tables(). Failure to do so caused crash when the same table was
marked as constant two times

mysql-test/r/table_elim.result:
  LPBUG#524025 Running RQG outer_join test leads to crash
  - Testcase
mysql-test/t/table_elim.test:
  LPBUG#524025 Running RQG outer_join test leads to crash
  - Testcase
sql/sql_select.cc:
  LPBUG#524025 Running RQG outer_join test leads to crash
  Save no-records constant tables in JOIN::const_table_map before we invoke eliminate_tables(). Failure to do so caused crash when the same table was marked as constant two times.
2010-03-06 15:09:02 +03:00
Sergey Petrunya
69028d5127 LPBUG#523593: Running RQG optimizer_no_subquery crashes MariaDB
- When analying multiple equalities, take into account that they 
  may not have a single table field that belongs to one of the tables
  that we're trying to eliminate (and they are not useful for table
  elimination in that case)

mysql-test/r/table_elim.result:
  LPBUG#523593: Running RQG optimizer_no_subquery crashes MariaDB
  - Testcase
mysql-test/t/table_elim.test:
  LPBUG#523593: Running RQG optimizer_no_subquery crashes MariaDB
  - Testcase
2010-02-18 15:03:52 +03:00
Igor Babaev
4449a5f489 Backport into MariaDB-5.2 the following:
WL#2771 "Block Nested Loop Join and Batched Key Access Join"
2009-12-20 18:26:15 -08:00
Sergey Petrunya
96e092dc73 Backport into MariaDB-5.2 the following:
WL#2474 "Multi Range Read: Change the default MRR implementation to implement new MRR interface"
WL#2475 "Batched range read functions for MyISAM/InnoDb"
        "Index condition pushdown for MyISAM/InnoDB"
Igor's fix from sp1r-igor@olga.mysql.com-20080330055902-07614:
  There could be observed the following problems:
  1. EXPLAIN did not mention pushdown conditions from on expressions in the 
  'extra' column.  As a result if a query had no where conditions pushed 
  down to a table, but had on conditions pushed to this table the 'extra' 
  column in the EXPLAIN for the table missed 'using where'.
  2. Conditions for ref access were not eliminated from on expressions 
  though such conditions were eliminated from the where condition.
2009-12-15 10:16:46 +03:00
Sergey Petrunya
2f93e7cd3f MWL#17: Table elimination: fixes for windows
include/my_global.h:
  MWL#17: Table elimination: fixes for windows
  - Add ALIGN_MAX_UNIT (assume malloc returns data aligned to this much)
mysql-test/r/table_elim.result:
  MWL#17: Table elimination: fixes for windows
  - Use only lower-case as EXPLAIN [EXTENDED] changes case of table names
    on windows
mysql-test/t/table_elim.test:
  MWL#17: Table elimination: fixes for windows
  - Use only lower-case as EXPLAIN [EXTENDED] changes case of table names
    on windows
sql/opt_table_elimination.cc:
  MWL#17: Table elimination: fixes for windows
  - Add extra alignment-padding-space for stack-allocated buffers.
2009-09-16 23:05:03 +04:00
Sergey Petrunya
005c24e973 MWL#17: Table elimination:
- Fix a trivial problem when OR-merging two multi-equalities
- Amend testsuite to provide full gcov coverage

mysql-test/r/table_elim.result:
  MWL#17: Table elimination:
  - Amend testsuite to provide full gcov coverage
mysql-test/t/table_elim.test:
  MWL#17: Table elimination:
  - Amend testsuite to provide full gcov coverage
2009-08-27 01:01:40 +04:00
Sergey Petrunya
de41681afa MWL#17: Table elimination
- More test coverage
- Remove unused code
2009-08-25 13:38:22 +03:00
Sergey Petrunya
9400700b99 MWL#17: Table elimination
- Add more testcases.
- Fix trivial compile failure
- Remove handling of "column IN (one_element)". This is converted to equality 
  elsewhere

mysql-test/r/table_elim.result:
  MWL#17: Table elimination
  - Add more testcases.
  - Fix trivial compile failure
mysql-test/t/table_elim.test:
  MWL#17: Table elimination
  - Add more testcases
sql/mysqld.cc:
  MWL#17: Table elimination
  - Fix trivial compile failure
sql/opt_table_elimination.cc:
  MWL#17: Table elimination
  - Add more testcases.
  - Remove handling of "column IN (one_element)".This is converted to equality 
    elsewhere
2009-08-25 12:27:50 +03:00
Sergey Petrunya
21d2573908 MWL#17: Table elimination
- Correctly handle the case where we have multi-table DELETE and a table
  that we're deleting from looks like it could be eliminated.
2009-08-24 10:12:42 +02:00
Sergey Petrunya
9c1336801e MWL#17: Table elimination
- More testcases
- Set correct dependencies for non-bound multi-equalities.

mysql-test/r/table_elim.result:
  MWL#17: Table elimination
  - More testcases
mysql-test/t/table_elim.test:
  MWL#17: Table elimination
  - More testcases
sql/opt_table_elimination.cc:
  MWL#17: Table elimination
  - Set correct dependencies for non-bound multi-equalities.
2009-08-21 09:48:22 +02:00
Sergey Petrunya
049c87fc2e MWL#17: Table elimination
- More testcases
2009-08-17 19:07:24 +03:00
Sergey Petrunya
441434e565 MWL#17: Table elimination
- More dbug printouts
- More testcases
2009-08-17 18:02:29 +03:00
Sergey Petrunya
9fa1bce436 MWL#17: Table elimination
mysql-test/r/table_elim.result:
  MWL#17: Table elimination
  - More tests
mysql-test/t/table_elim.test:
  MWL#17: Table elimination
  - More tests
sql/opt_table_elimination.cc:
  MWL#17: Table elimination
  - Code cleanup
sql/sql_select.cc:
  MWL#17: Table elimination
  - Code cleanup
sql/sql_select.h:
  MWL#17: Table elimination
  - Code cleanup
sql/table.h:
  MWL#17: Table elimination
  - Code cleanup
2009-06-29 17:51:15 +04:00
Sergey Petrunia
c4922cbf10 MWL#17: Table elimination
- More testcases
- Let add_ft_key() set keyuse->usable

mysql-test/r/table_elim.result:
  MWL#17: Table elimination
  - More testcases
mysql-test/t/table_elim.test:
  MWL#17: Table elimination
  - More testcases
sql/sql_select.cc:
  MWL#17: Table elimination
  - Let add_ft_key() set keyuse->usable
2009-06-24 00:06:13 +04:00
Sergey Petrunia
402e58cf78 MWL#17: Table elimination
- Do not show eliminated tables in the output of EXPLAIN EXTENDED
2009-06-14 14:01:10 +04:00
Sergey Petrunia
fd485ad988 MWL#17: Table elimination
- Make elimination work with aggregate functions. The problem was that aggregate functions 
  reported all table bits in used_tables(), and that prevented table elimination. Fixed by 
  making aggregate functions return more correct value from used_tables(). 

mysql-test/r/ps_11bugs.result:
  MWL#17: Table elimination
  - Update test results. The difference is because of Item_ref change: outer references to constants
    are now recognized as constants, too.
mysql-test/r/subselect.result:
  - Update test results. The difference is because of Item_ref change: outer references to constants
    are now recognized as constants, too.
mysql-test/r/table_elim.result:
  MWL#17: Table elimination
  - Check that elimination works in presense of aggreagate functions
mysql-test/t/table_elim.test:
  MWL#17: Table elimination
  - Check that elimination works in presense of aggreagate functions
sql/item.h:
  MWL#17: Table elimination
  - Add Item_ref::const_item() which calls (*ref)->const_item(). Before this diff Item_ref used the 
    default implementation of const_item(){ return used_tables()==0; }. This is no longer true, as 
    COUNT(*) now has used_tables()==0 but const_item()==FALSE.
sql/item_sum.cc:
  MWL#17: Table elimination
  - Make Item_sum() and it descendants not to return all bits in used_tables(). This is needed 
    because otherwise table elimination can't work in presense of aggregate functions
  - COUNT(*) now has used_tables()==0 and const_item()==FALSE. Had to change 
    Item_ref::const_item() to account for this.
sql/item_sum.h:
  MWL#17: Table elimination
  - Add comments
2009-06-10 01:11:33 +04:00
Sergey Petrunia
275a4b354b MWL#17: Table elimination
- First code. Elimination works for simple cases, passes the testsuite.
- Known issues:
  = No elimination is done for aggregate functions.
  = EXPLAIN EXTENDED shows eliminated tables (I think it better not)
  = No benchmark yet
  = The code needs some polishing.

mysql-test/r/table_elim.result:
  MWL#17: Table elimination
  - Testcases
mysql-test/t/table_elim.test:
  MWL#17: Table elimination
  - Testcases
sql/sql_select.cc:
  MWL#17: Table elimination
sql/sql_select.h:
  MWL#17: Table elimination
  - Added JOIN_TAB::eliminated (is JOIN_TAB the best place to store this flag?)
sql/table.h:
  MWL#17: Table elimination
  - ADded NESTED_JOIN::n_tables. We need to have the number of real tables remaining in an outer join nest.
2009-06-03 17:10:45 +04:00