summaryrefslogtreecommitdiff
path: root/sql/ha_partition.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2022-09-23 14:48:13 +0300
committerSergei Petrunia <sergey@mariadb.com>2023-02-02 23:54:57 +0300
commit009db2288ba8d22c5e8e5e047d8f8694f7097923 (patch)
tree96fba5cb7598afd162f464adb522b59c1ef90605 /sql/ha_partition.cc
parentb66cdbd1eaeed7e96317a03a190c496fd062ec71 (diff)
downloadmariadb-git-009db2288ba8d22c5e8e5e047d8f8694f7097923.tar.gz
Fixed limit optimization in range optimizer
The issue was that when limit is used, SQL_SELECT::test_quick_select would set the cost of table scan to be unreasonable high to force a range to be used. The problem with this approach was that range was used even when the cost of range, when it would only read 'limit rows' would be higher than the cost of a table scan. This patch fixes it by not accepting ranges when the range can never have a lower cost than a table scan, even if every row would match the WHERE clause.
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r--sql/ha_partition.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 701bffd8dd7..30c1832fadc 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -6575,7 +6575,7 @@ ha_rows ha_partition::multi_range_read_info_const(uint keyno,
RANGE_SEQ_IF *seq,
void *seq_init_param,
uint n_ranges, uint *bufsz,
- uint *mrr_mode,
+ uint *mrr_mode, ha_rows limit,
Cost_estimate *cost)
{
int error;
@@ -6636,7 +6636,7 @@ ha_rows ha_partition::multi_range_read_info_const(uint keyno,
&m_partition_part_key_multi_range_hld[i],
m_part_mrr_range_length[i],
&m_mrr_buffer_size[i],
- &tmp_mrr_mode, &part_cost);
+ &tmp_mrr_mode, limit, &part_cost);
if (tmp_rows == HA_POS_ERROR)
{
m_part_spec= save_part_spec;