mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Adjust costs for doing index scan in cost_group_min_max()
The idea is that when doing a tree dive (once per group), we need to compare key values, which is fast. For each new group, we have to compare the full where clause for the row. Compared to original code, the cost of group_min_max() has slightly increased which affects some test with only a few rows. main.group_min_max and main.distinct have been modified to show the effect of the change. The patch also adjust the number of groups in case of quick selects: - For simple WHERE clauses, ensure that we have at least as many groups as we have conditions on the used group-by key parts. The assumption is that each condition will create at least one group. - Ensure that there are no more groups than rows found by quick_select Test changes: - For some small tables there has been a change of Using index for group-by -> Using index for group-by (scanning) Range -> Index and Using index for group-by -> Using index
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
#
|
||||
|
||||
--source include/default_optimizer_switch.inc
|
||||
--source include/have_sequence.inc
|
||||
--disable_warnings
|
||||
drop table if exists t1,t2,t3;
|
||||
--enable_warnings
|
||||
@ -574,9 +575,10 @@ INSERT INTO t1(a, b, c) VALUES (1, 1, 1),
|
||||
(1, 2, 2),
|
||||
(1, 2, 3);
|
||||
|
||||
EXPLAIN SELECT DISTINCT a, b, d, c FROM t1;
|
||||
|
||||
SELECT DISTINCT a, b, d, c FROM t1;
|
||||
EXPLAIN SELECT DISTINCT a, b, d, c FROM t1;
|
||||
INSERT INTO t1 SELECT seq/10,seq/10,seq/10,seq/10,seq from seq_1_to_100;
|
||||
EXPLAIN SELECT DISTINCT a, b, d, c FROM t1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
|
Reference in New Issue
Block a user