From 45b35eaf977430a8fda304c0054eb0f5efb3a96e Mon Sep 17 00:00:00 2001 From: chenlinfeng <723609220@qq.com> Date: Mon, 18 Oct 2021 11:23:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=81=E6=AD=A2=E5=A4=9A=E5=8C=BA=E9=97=B4?= =?UTF-8?q?=E5=88=87=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/handler.cc | 1 + storage/innobase/handler/handler0alter.cc | 10 +++++----- storage/innobase/include/row0pread.h | 5 ++++- storage/innobase/row/row0pread.cc | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index e283ef34cc9f..a22a51a78e83 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6376,6 +6376,7 @@ int handler::multi_range_read_init(RANGE_SEQ_IF *seq_funcs, DBUG_TRACE; mrr_iter = seq_funcs->init(seq_init_param, n_ranges, mode); mrr_funcs = *seq_funcs; + ranges_in_seq = n_ranges; mrr_is_output_sorted = mode & HA_MRR_SORTED; mrr_have_range = false; return 0; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 25e8b935b577..fa90c3b1d1a1 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -1296,7 +1296,7 @@ int ha_innobase::pq_leader_range_select_scan_init(uint keyno, void *&pq_ctx, uin config.m_range_errno = range_errno; config.m_pcur = pcur; config.m_pq_reverse_scan = pq_reverse_scan; - + config.m_is_single_range = ranges_in_seq == 1; auto success = pq_reader->add_scan(trx, config, nullptr,false); pq_reader->snapshot = trx->read_view; @@ -1416,7 +1416,7 @@ int ha_innobase::pq_leader_ref_init(uint keyno, void *&pq_ctx, uint &n_threads) config.m_range_errno = range_errno; config.m_pcur = pcur; config.m_pq_reverse_scan = pq_reverse_scan; - + config.m_is_single_range = true; auto success = pq_reader->add_scan(trx, config, nullptr, false); pq_reader->snapshot = trx->read_view; @@ -1509,7 +1509,7 @@ int ha_innobase::pq_leader_scan_init(uint keyno, void *&pq_ctx, uint &n_threads) config.m_range_errno = ret; config.m_pcur = pcur; config.m_pq_reverse_scan = pq_reverse_scan; - + config.m_is_single_range = true; auto success = pq_reader->add_scan(trx, config, nullptr, false); pq_reader->snapshot = trx->read_view; @@ -1666,7 +1666,7 @@ int ha_innobase::parallel_scan_init(void *&scan_ctx, size_t &num_threads) { Parallel_reader::Scan_range full_scan{}; Parallel_reader::Config config(full_scan, m_prebuilt->table->first_index()); - + config.m_is_single_range = true; dberr_t err = adapter->add_scan(trx, config, [=](const Parallel_reader::Ctx *ctx) { return (adapter->process_rows(ctx)); @@ -10270,7 +10270,7 @@ int ha_innopart::parallel_scan_init(void *&scan_ctx, size_t &num_threads) { Parallel_reader::Config config(FULL_SCAN, m_prebuilt->table->first_index(), 0, dd_partitions[i]->number()); - + config.m_is_single_range = true; dberr_t err = adapter->add_scan(trx, config, [=](const Parallel_reader::Ctx *ctx) { return (adapter->process_rows(ctx)); diff --git a/storage/innobase/include/row0pread.h b/storage/innobase/include/row0pread.h index 0ebf957e110a..d581f862a128 100644 --- a/storage/innobase/include/row0pread.h +++ b/storage/innobase/include/row0pread.h @@ -184,7 +184,8 @@ class Parallel_reader { m_read_ahead(config.m_read_ahead), m_range_errno(config.m_range_errno), m_pcur(config.m_pcur), - m_pq_reverse_scan(config.m_pq_reverse_scan) {} + m_pq_reverse_scan(config.m_pq_reverse_scan), + m_is_single_range(config.m_is_single_range) {} ~Config() { } @@ -216,6 +217,8 @@ class Parallel_reader { btr_pcur_t *m_pcur{nullptr}; bool m_pq_reverse_scan{false}; + + bool m_is_single_range{false}; }; /** Constructor. diff --git a/storage/innobase/row/row0pread.cc b/storage/innobase/row/row0pread.cc index 748706fcc543..dc9cfaea883b 100644 --- a/storage/innobase/row/row0pread.cc +++ b/storage/innobase/row/row0pread.cc @@ -1384,7 +1384,7 @@ dberr_t Parallel_reader::Scan_ctx::create_ranges(const Scan_range &scan_range, page_cur_move_to_next(&page_cursor); } - if (ranges.size() == 1 && depth == split_level) { + if (ranges.size() == 1 && depth == split_level && m_config.m_is_single_range) { if (at_leaf) { ranges.clear(); while (!page_cur_is_after_last(&start_page_cursor)) {