From 488a0dd905699f9a7331087398fdf4f1996f2c97 Mon Sep 17 00:00:00 2001 From: leipeng Date: Wed, 1 Nov 2023 23:17:05 +0800 Subject: [PATCH] select_random_ranges: add secondary_ranges == 3 for mysql mrr range_size rows --- src/lua/select_random_ranges.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lua/select_random_ranges.lua b/src/lua/select_random_ranges.lua index 14c6be9b..b72f8213 100755 --- a/src/lua/select_random_ranges.lua +++ b/src/lua/select_random_ranges.lua @@ -51,6 +51,14 @@ function thread_init() SELECT count(*), sum(length(c)) FROM sbtest1 WHERE id IN (SELECT * FROM (SELECT id FROM sbtest1 WHERE %s LIMIT %d) as t)]], ranges, sysbench.opt.range_size)) + elseif (sysbench.opt.secondary_ranges == 3) then + -- MySQL does not generate MRR query plan for secondary_ranges == 2, + -- We add secondary_ranges == 3 as the query for get range_size rows + -- by MRR, secondary_ranges == 1 likely get more rows than range_size. + stmt = con:prepare(string.format([[ + SELECT length(c) + FROM sbtest1 + WHERE %s LIMIT %d]], ranges, sysbench.opt.range_size)) else stmt = con:prepare(string.format([[ SELECT sum(length(c))