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/subselect2.result | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'mysql-test/main/subselect2.result') diff --git a/mysql-test/main/subselect2.result b/mysql-test/main/subselect2.result index 31e7774734e..76208429184 100644 --- a/mysql-test/main/subselect2.result +++ b/mysql-test/main/subselect2.result @@ -286,8 +286,8 @@ WHERE date < '2012-12-12 12:12:12' ORDER BY mirror_date ASC ) AS calculated_result; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL NULL NULL NULL NULL 2 -2 DERIVED t1 range date date 6 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using filesort +1 PRIMARY ALL NULL NULL NULL NULL 3 +2 DERIVED t1 ALL date NULL NULL NULL 3 Using where; Using filesort SELECT * FROM ( SELECT node_uid, date, mirror_date, @result := 0 AS result FROM t1 @@ -309,8 +309,8 @@ WHERE date < '2012-12-12 12:12:12' ORDER BY mirror_date ASC ) AS calculated_result; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL NULL NULL NULL NULL 2 -2 DERIVED t1 range date date 6 NULL 2 Using index condition; Using where; Using filesort +1 PRIMARY ALL NULL NULL NULL NULL 3 +2 DERIVED t1 ALL date NULL NULL NULL 3 Using where; Using filesort SELECT * FROM ( SELECT node_uid, date, mirror_date, @result := 0 AS result FROM t1 -- cgit v1.2.1