From 33c66eb7fbcddb09217820708e8ce9324e65db11 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Aug 2013 10:51:08 +0300 Subject: MDEV-4120: UNIQUE indexes should not be considered for loose index scan Currently the loose scan code in opt_range.cc considers all indexes as possible for the access method. Due to inexact statistics it may happen that a loose scan is selected over a unique index. This is clearly wrong since a "loose scan" over a unique index will read the same keys as a direct index scan, but the loose scan has more overhead. This task adds a rule to skip unique indexes for loose scan. --- mysql-test/r/distinct.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mysql-test/r/distinct.result') diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index 459ece978fd..d23a6706e04 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -756,7 +756,7 @@ INSERT INTO t1(a, b, c) VALUES (1, 1, 1), (1, 2, 3); EXPLAIN SELECT DISTINCT a, b, d, c FROM t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL PRIMARY 16 NULL 7 Using index for group-by; Using temporary +1 SIMPLE t1 range NULL a 16 NULL 7 Using index for group-by SELECT DISTINCT a, b, d, c FROM t1; a b d c 1 1 0 1 -- cgit v1.2.1