mirror of
https://github.com/MariaDB/server.git
synced 2025-02-15 01:45:33 +01:00
![Monty](/assets/img/avatar_default.png)
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)
45 lines
1.6 KiB
Text
45 lines
1.6 KiB
Text
SET @default_storage_engine_old = @@session.default_storage_engine;
|
|
SET SESSION default_storage_engine = INNODB;
|
|
FLUSH INDEX_STATISTICS;
|
|
FLUSH TABLE_STATISTICS;
|
|
SET @userstat_old= @@userstat;
|
|
SET GLOBAL userstat=ON;
|
|
CREATE TABLE t1 (id int(10), PRIMARY KEY (id));
|
|
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
|
|
SELECT COUNT(*) FROM t1;
|
|
COUNT(*)
|
|
10
|
|
SELECT ROWS_READ FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME='t1';
|
|
ROWS_READ
|
|
10
|
|
SELECT ROWS_READ FROM INFORMATION_SCHEMA.INDEX_STATISTICS WHERE TABLE_NAME='t1';
|
|
ROWS_READ
|
|
FLUSH TABLE_STATISTICS;
|
|
SELECT ROWS_READ FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME='t1';
|
|
ROWS_READ
|
|
SELECT ROWS_READ FROM INFORMATION_SCHEMA.INDEX_STATISTICS WHERE TABLE_NAME='t1';
|
|
ROWS_READ
|
|
FLUSH INDEX_STATISTICS;
|
|
SELECT ROWS_READ FROM INFORMATION_SCHEMA.INDEX_STATISTICS WHERE TABLE_NAME='t1';
|
|
ROWS_READ
|
|
SELECT COUNT(*) FROM t1;
|
|
COUNT(*)
|
|
10
|
|
SELECT ROWS_READ FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME='t1';
|
|
ROWS_READ
|
|
10
|
|
SELECT ROWS_READ FROM INFORMATION_SCHEMA.INDEX_STATISTICS WHERE TABLE_NAME='t1';
|
|
ROWS_READ
|
|
DROP TABLE t1;
|
|
CREATE TABLE t2 (c1 INT UNSIGNED);
|
|
ALTER TABLE t2 MODIFY c1 FLOAT;
|
|
SELECT * FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME='t2';
|
|
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
|
|
DROP TABLE t2;
|
|
CREATE TABLE t2 (c1 INT UNSIGNED);
|
|
ALTER TABLE t2 MODIFY c1 FLOAT;
|
|
SELECT * FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME='t2';
|
|
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
|
|
DROP TABLE t2;
|
|
SET GLOBAL userstat= @userstat_old;
|
|
SET SESSION default_storage_engine = @default_storage_engine_old;
|