1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Added test cases for preceding test

This includes all test changes from
"Changing all cost calculation to be given in milliseconds"
and forwards.

Some of the things that caused changes in the result files:

- As part of fixing tests, I added 'echo' to some comments to be able to
  easier find out where things where wrong.
- MATERIALIZED has now a higher cost compared to X than before. Because
  of this some MATERIALIZED types have changed to DEPENDEND SUBQUERY.
  - Some test cases that required MATERIALIZED to repeat a bug was
    changed by adding more rows to force MATERIALIZED to happen.
- 'Filtered' in SHOW EXPLAIN has in many case changed from 100.00 to
  something smaller. This is because now filtered also takes into
  account the smallest possible ref access and filters, even if they
  where not used. Another reason for 'Filtered' being smaller is that
  we now also take into account implicit filtering done for subqueries
  using FIRSTMATCH.
  (main.subselect_no_exists_to_in)
  This is caluculated in best_access_path() and stored in records_out.
- Table orders has changed because more accurate costs.
- 'index' and 'ALL' for small tables has changed to use 'range' or
   'ref' because of optimizer_scan_setup_cost.
- index can be changed to 'range' as 'range' optimizer assumes we don't
  have to read the blocks from disk that range optimizer has already read.
  This can be confusing in the case where there is no obvious where clause
  but instead there is a hidden 'key_column > NULL' added by the optimizer.
  (main.subselect_no_exists_to_in)
- Scan on primary clustered key does not report 'Using Index' anymore
  (It's a table scan, not an index scan).
- For derived tables, the number of rows is now 100 instead of 2,
  which can be seen in EXPLAIN.
- More tests have "Using index for group by" as the cost of this
  optimization is now more correct (lower).
- A primary key could be preferred for a normal key, even if it would
  access more rows, as it's faster to do 1 lokoup and 3 'index_next' on a
  clustered primary key than one lookup trough a secondary.
  (main.stat_tables_innodb)

Notes:

- There was a 4.7% more calls to best_extension_by_limited_search() in
  the main.greedy_optimizer test.  However examining the test results
  it looked that the plans where slightly better (eq_ref where more
  chained together) so I assume this is ok.
- I have verified a few test cases where there was notable/unexpected
  changes in the plan and in all cases the new optimizer plans where
  faster.  (main.greedy_optimizer and some others)
This commit is contained in:
Monty
2022-10-04 16:16:06 +03:00
committed by Sergei Petrunia
parent eb68023c8e
commit 727491b72a
290 changed files with 10927 additions and 8874 deletions

View File

@ -154,8 +154,8 @@ alter table t3 add index(id2);
explain extended select t1.*, t2.*, t3.*
from t1 join t2 using (id1) join t3 using (id2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL id1 NULL NULL NULL 10 100.00 Using where
1 SIMPLE t2 ref id2,id1 id1 5 test.t1.id1 10 100.00 Using where
1 SIMPLE t1 ALL id1 NULL NULL NULL 10 100.00
1 SIMPLE t2 ALL id2,id1 NULL NULL NULL 100 10.00 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t3 ref id2 id2 5 test.t2.id2 10 100.00
Warnings:
Note 1003 select `test`.`t1`.`id1` AS `id1`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t3`.`id2` = `test`.`t2`.`id2` and `test`.`t2`.`id1` = `test`.`t1`.`id1`
@ -167,7 +167,7 @@ number_seen OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME INDEX_NAME OPERATION NUMBER_OF
11 TABLE test t1 NULL fetch 1
1 TABLE test t1 id1 read external NULL
1 TABLE test t1 id1 read normal NULL
110 TABLE test t2 id1 fetch 1
101 TABLE test t2 NULL fetch 1
1 TABLE test t2 id2 read external NULL
1 TABLE test t2 id2 read normal NULL
100 TABLE test t3 id2 fetch 10
@ -177,14 +177,15 @@ OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME INDEX_NAME COUNT_STAR COUNT_READ COUNT_WRI
TABLE test t0 NULL 0 0 0
TABLE test t1 NULL 11 11 0
TABLE test t1 id1 0 0 0
TABLE test t2 id1 110 110 0
TABLE test t2 NULL 101 101 0
TABLE test t2 id1 0 0 0
TABLE test t2 id2 0 0 0
TABLE test t3 id2 1000 1000 0
TABLE test t3 id3 0 0 0
OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME COUNT_STAR COUNT_READ COUNT_WRITE
TABLE test t0 0 0 0
TABLE test t1 11 11 0
TABLE test t2 110 110 0
TABLE test t2 101 101 0
TABLE test t3 1000 1000 0
drop table t0;
drop table t1;