From 658128af43b4d7c6db445164f8ed25ed4d1e3109 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sun, 3 Feb 2019 14:56:12 -0800 Subject: MDEV-16188 Use in-memory PK filters built from range index scans MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch contains a full implementation of the optimization that allows to use in-memory rowid / primary filters built for range   conditions over indexes. In many cases usage of such filters reduce   the number of disk seeks spent for fetching table rows. In this implementation the choice of what possible filter to be applied   (if any) is made purely on cost-based considerations. This implementation re-achitectured the partial implementation of the feature pushed by Galina Shalygina in the commit 8d5a11122c32f4d9eb87536886c6e893377bdd07. Besides this patch contains a better implementation of the generic   handler function handler::multi_range_read_info_const() that takes into account gaps between ranges when calculating the cost of range index scans. It also contains some corrections of the implementation of the handler function records_in_range() for MyISAM. This patch supports the feature for InnoDB and MyISAM. --- mysql-test/main/invisible_field_debug.result | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'mysql-test/main/invisible_field_debug.result') diff --git a/mysql-test/main/invisible_field_debug.result b/mysql-test/main/invisible_field_debug.result index b3c84d18333..64f1d7f720e 100644 --- a/mysql-test/main/invisible_field_debug.result +++ b/mysql-test/main/invisible_field_debug.result @@ -329,6 +329,9 @@ insert into t1 values(1,1,1); insert into t1 values(2,2,2); insert into t1 values(3,3,3); insert into t1 values(4,4,4); +insert into t1 values(5,5,5); +insert into t1 values(6,6,6); +insert into t1 values(7,7,7); set debug_dbug= "+d,test_completely_invisible,test_invisible_index"; select invisible, a ,b from t1 order by b; invisible a b @@ -336,9 +339,12 @@ invisible a b 9 2 2 9 3 3 9 4 4 +9 5 5 +9 6 6 +9 7 7 explain select * from t1 where invisible =9; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref invisible invisible 5 const 3 +1 SIMPLE t1 ALL invisible NULL NULL NULL 7 Using where alter table t1 add x int default 3; select invisible, a ,b from t1; invisible a b @@ -346,6 +352,9 @@ invisible a b 9 2 2 9 3 3 9 4 4 +9 5 5 +9 6 6 +9 7 7 set debug_dbug=@old_debug; Show index from t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment @@ -357,11 +366,11 @@ drop index invisible on t1; ERROR 42000: Can't DROP INDEX `invisible`; check that it exists explain select * from t1 where invisible =9; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref invisible invisible 5 const 3 +1 SIMPLE t1 ALL invisible NULL NULL NULL 7 Using where create index invisible on t1(c); explain select * from t1 where invisible =9; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref invisible_2 invisible_2 5 const 3 +1 SIMPLE t1 ALL invisible_2 NULL NULL NULL 7 Using where show indexes in t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment t1 1 b 1 b A NULL NULL NULL YES BTREE -- cgit v1.2.1