mirror of
https://github.com/MariaDB/server.git
synced 2025-01-27 09:14:17 +01:00
727491b72a
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)
154 lines
5.4 KiB
Text
154 lines
5.4 KiB
Text
--disable_warnings
|
|
DROP TABLE IF EXISTS t1,t2,t3;
|
|
--enable_warnings
|
|
|
|
CREATE TABLE t1 (
|
|
a INT AUTO_INCREMENT PRIMARY KEY,
|
|
message CHAR(20),
|
|
FULLTEXT(message)
|
|
) comment = 'original testcase by sroussey@network54.com';
|
|
INSERT INTO t1 (message) VALUES ("Testing"),("table"),("testbug"),
|
|
("steve"),("is"),("cool"),("steve is cool");
|
|
# basic MATCH
|
|
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve');
|
|
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve');
|
|
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE);
|
|
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE);
|
|
|
|
# MATCH + ORDER BY (with ft-ranges)
|
|
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY a;
|
|
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a;
|
|
|
|
# MATCH + ORDER BY (with normal ranges) + UNIQUE
|
|
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve') ORDER BY a DESC;
|
|
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a DESC;
|
|
|
|
# MATCH + ORDER BY + UNIQUE (const_table)
|
|
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve') ORDER BY 1;
|
|
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY 1;
|
|
|
|
# ORDER BY MATCH
|
|
SELECT IF(a=7,'steve-is-cool',IF(a=4,'cool', 'other')), FORMAT(MATCH (message) AGAINST ('steve'),6) as rel FROM t1 ORDER BY rel;
|
|
SELECT IF(a=7,'match',IF(a=4,'match', 'no-match')), MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel;
|
|
|
|
#
|
|
# BUG#6635 - test_if_skip_sort_order() thought it can skip filesort
|
|
# for fulltext searches too
|
|
#
|
|
alter table t1 add key m (message);
|
|
explain SELECT message FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY message;
|
|
SELECT message FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY message desc;
|
|
|
|
drop table t1;
|
|
|
|
#
|
|
# reused boolean scan bug
|
|
#
|
|
CREATE TABLE t1 (
|
|
a INT AUTO_INCREMENT PRIMARY KEY,
|
|
message CHAR(20),
|
|
FULLTEXT(message)
|
|
);
|
|
INSERT INTO t1 (message) VALUES ("testbug"),("testbug foobar");
|
|
SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1;
|
|
SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel,a;
|
|
drop table t1;
|
|
|
|
# BUG#11869
|
|
CREATE TABLE t1 (
|
|
id int(11) NOT NULL auto_increment,
|
|
thread int(11) NOT NULL default '0',
|
|
beitrag longtext NOT NULL,
|
|
PRIMARY KEY (id),
|
|
KEY thread (thread),
|
|
FULLTEXT KEY beitrag (beitrag)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7923 ;
|
|
|
|
CREATE TABLE t2 (
|
|
id int(11) NOT NULL auto_increment,
|
|
text varchar(100) NOT NULL default '',
|
|
PRIMARY KEY (id),
|
|
KEY text (text)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=63 ;
|
|
|
|
CREATE TABLE t3 (
|
|
id int(11) NOT NULL auto_increment,
|
|
forum int(11) NOT NULL default '0',
|
|
betreff varchar(70) NOT NULL default '',
|
|
PRIMARY KEY (id),
|
|
KEY forum (forum),
|
|
FULLTEXT KEY betreff (betreff)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=996 ;
|
|
|
|
--error ER_TABLENAME_NOT_ALLOWED_HERE
|
|
select a.text, b.id, b.betreff
|
|
from
|
|
t2 a inner join t3 b on a.id = b.forum inner join
|
|
t1 c on b.id = c.thread
|
|
where
|
|
match(b.betreff) against ('+abc' in boolean mode)
|
|
group by a.text, b.id, b.betreff
|
|
union
|
|
select a.text, b.id, b.betreff
|
|
from
|
|
t2 a inner join t3 b on a.id = b.forum inner join
|
|
t1 c on b.id = c.thread
|
|
where
|
|
match(c.beitrag) against ('+abc' in boolean mode)
|
|
group by
|
|
a.text, b.id, b.betreff
|
|
order by
|
|
match(b.betreff) against ('+abc' in boolean mode) desc;
|
|
|
|
--error ER_TABLENAME_NOT_ALLOWED_HERE
|
|
select a.text, b.id, b.betreff
|
|
from
|
|
t2 a inner join t3 b on a.id = b.forum inner join
|
|
t1 c on b.id = c.thread
|
|
where
|
|
match(b.betreff) against ('+abc' in boolean mode)
|
|
union
|
|
select a.text, b.id, b.betreff
|
|
from
|
|
t2 a inner join t3 b on a.id = b.forum inner join
|
|
t1 c on b.id = c.thread
|
|
where
|
|
match(c.beitrag) against ('+abc' in boolean mode)
|
|
order by
|
|
match(b.betreff) against ('+abc' in boolean mode) desc;
|
|
|
|
select a.text, b.id, b.betreff
|
|
from
|
|
t2 a inner join t3 b on a.id = b.forum inner join
|
|
t1 c on b.id = c.thread
|
|
where
|
|
match(b.betreff) against ('+abc' in boolean mode)
|
|
union
|
|
select a.text, b.id, b.betreff
|
|
from
|
|
t2 a inner join t3 b on a.id = b.forum inner join
|
|
t1 c on b.id = c.thread
|
|
where
|
|
match(c.beitrag) against ('+abc' in boolean mode)
|
|
order by
|
|
match(betreff) against ('+abc' in boolean mode) desc;
|
|
|
|
# BUG#11869 part2: used table type doesn't support FULLTEXT indexes error
|
|
(select b.id, b.betreff from t3 b) union
|
|
(select b.id, b.betreff from t3 b)
|
|
order by match(betreff) against ('+abc' in boolean mode) desc;
|
|
|
|
--error 1191
|
|
(select b.id, b.betreff from t3 b) union
|
|
(select b.id, b.betreff from t3 b)
|
|
order by match(betreff) against ('+abc') desc;
|
|
|
|
select distinct b.id, b.betreff from t3 b
|
|
order by match(betreff) against ('+abc' in boolean mode) desc;
|
|
|
|
select b.id, b.betreff from t3 b group by b.id+1
|
|
order by match(betreff) against ('+abc' in boolean mode) desc;
|
|
|
|
drop table t1,t2,t3;
|
|
|
|
# End of 4.1 tests
|