From 17b5cee3603d832f2d1239dcd961de77c7e1b75b Mon Sep 17 00:00:00 2001 From: time-and-fate <25057648+time-and-fate@users.noreply.github.com> Date: Mon, 15 Apr 2024 18:56:36 +0800 Subject: [PATCH 1/2] fix --- .../core/indexmerge_unfinished_path.go | 2 +- .../r/planner/core/indexmerge_path.result | 22 +++++++++++++++++++ .../t/planner/core/indexmerge_path.test | 16 ++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/pkg/planner/core/indexmerge_unfinished_path.go b/pkg/planner/core/indexmerge_unfinished_path.go index 19c077165863e..0988f4175bc3c 100644 --- a/pkg/planner/core/indexmerge_unfinished_path.go +++ b/pkg/planner/core/indexmerge_unfinished_path.go @@ -411,7 +411,7 @@ func buildIntoAccessPath( // 2. Collect the final table filter // We always put all filters in the top level AND list except for the OR list into the final table filters. // Whether to put the OR list into the table filters also depends on the needSelectionGlobal. - tableFilter := allConds[:] + tableFilter := slices.Clone(allConds) if !needSelectionGlobal { tableFilter = slices.Delete(tableFilter, orListIdxInAllConds, orListIdxInAllConds+1) } diff --git a/tests/integrationtest/r/planner/core/indexmerge_path.result b/tests/integrationtest/r/planner/core/indexmerge_path.result index f59dd2fbe3b88..404bee7b1a953 100644 --- a/tests/integrationtest/r/planner/core/indexmerge_path.result +++ b/tests/integrationtest/r/planner/core/indexmerge_path.result @@ -963,3 +963,25 @@ Projection_8 6.66 root planner__core__indexmerge_path.t.col_37->Column#7 └─TableRowIDScan_11 10.00 cop[tikv] table:t keep order:false, stats:pseudo SELECT /*+ use_index_merge(t)*/ MIN(col_37) FROM t WHERE col_38 BETWEEN '1984-12-13' AND '1975-01-28' OR JSON_CONTAINS(col_37, '138480458355390957') GROUP BY col_38 HAVING col_38 != '1988-03-22'; MIN(col_37) +drop table if exists t1; +CREATE TABLE `t1` ( +`col_44` date NOT NULL, +`col_45` json DEFAULT NULL, +`col_46` blob NOT NULL, +PRIMARY KEY (`col_44`) /*T![clustered_index] CLUSTERED */, +UNIQUE KEY `idx_16` (`col_46`(3)), +KEY `idx_17` ((cast(`col_45` as double array))) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; +INSERT INTO `t1` VALUES('1970-06-23','[0.4560478695486992, 0.803651626010387]',x'7536255340506e4c33316848237a35'),('1970-09-25','[0.15199642284684986, 0.6321478001858613, 0.7656785642600782]',x'46257656295764673d4d2879486a7064'),('1970-12-20','[0.1945757596453029, 0.805924917565015, 0.9514989635078432]',x'3237585f587937596440666c'),('1971-01-30','[0.8674221724194489, 0.5874297776348085, 0.953305932613583, 0.3597865188732217, 0.9685946450023771]',x'776435472d306a'),('1971-04-19','[0.3962760654250889, 0.3033630486210956, 0.5788307700170308, 0.45967119199449186, 0.18040912218010932]',x'5f6e595446'),('1971-07-13','[0.5430757366310748, 0.8018899907743144, 0.8380302518531714, 0.13858586403286638]',x'4c2a4a4f71402d476b61796e7975426859'),('1971-09-08','[0.5866539910043066, 0.47465227377222047, 0.3412140234543155, 0.8109510241444171, 0.7217020139220653]',x'21326e4240524d626451467226624d36473264'),('1974-03-11','[0.9692492406521573]',x'7625754e5e55'),('1974-06-21','[0.8026878685767292]',x'7233744b2340285f'),('1975-06-08','[0.9922869004082567, 0.13102472710817054, 0.6557189141392675, 0.7616974552959114, 0.9653986970900055]',x'384261614d'),('1977-10-19','[0.33915755092357786, 0.612813632848902, 0.31310578556186824, 0.7695374222593716, 0.6996560322741089]',x'436d37594d7529734e412d513339'),('1978-01-31','[0.9327357034423996, 0.5066011929178722, 0.35172580278260285]',x'5f2145376d3742284254726971374f6d62'),('1978-08-23','[0.05090948016614748]',x'42485a4e322d2444'),('1980-03-16','[0.49342945147794093, 0.3032388374311525, 0.7358262102414459, 0.28035992762300044, 0.9099270917809736]',x'244863456e506b4024366e7a5f4a4a4645'),('1981-11-13','[0.014281917443517428, 0.31751875796372186, 0.5653893294127147, 0.6252442676826157, 0.6354719008300445]',x'4959463d2d6359796e377854754d2470'),('1983-10-16','[0.6992056327393458, 0.6285491992936737]',x'5175714844556626514743434b7543314249'),('1984-04-16','[0.5253196030542662, 0.3561411260568334, 0.7687615143503639, 0.4271982783883207, 0.20382816433225448]',x'475176'),('1988-07-19','[0.9233398239291353, 0.9396459773262974, 0.540018481999012, 0.181978533893545]',x'652539286c5f7e6b482a7265575a'),('1988-08-27','[0.9206220563718938]',x'475f693338392b646847'),('1989-12-07','[0.7964395106523453, 0.15227139590401054, 0.008643835436697868, 0.49470337240413564, 0.421379488694248]',x'377a767a65517647364856'),('1994-09-19','[0.19716919785297451]',x'3d26'),('1994-10-09',NULL,x'2a475463505136376861'),('1997-01-28','[0.30777386345347096]',x'70335e5e506b34236231476c35465e5e6d7448'),('2003-03-20','[0.23787267537350917, 0.5250550691578201, 0.9997853645717626]',x'404925286e5e726b305e'),('2004-04-12','[0.5368094270222808, 0.5306352503604773]',x'3752686b497448347039462136405a4f7a32'),('2005-02-04','[0.6531851579067487, 0.43849173297844984]',x'7e472a33336e73374558386a47234d5578'),('2005-02-18','[0.6303813789290023, 0.8178417890758697, 0.5354859968496037, 0.8868549026347942, 0.7253817513425349]',x'7e2d426a566329774a566c24217729797824'),('2005-05-09','[0.4155497358943851, 0.7649690762144056, 0.08552617826430448, 0.8054846042993035, 0.40076060531272734]',x''),('2006-02-10','[0.0506631513523112]',x'54416c7752526b55695258'),('2006-05-28','[0.7391997763354717, 0.43722943543743453, 0.8497153956761379, 0.8287059733052305, 0.8111927284482152]',x'38306635334126614d3455717e6b5762'),('2006-12-11','[0.11237614634576035, 0.33642094098687275]',x'57'),('2008-11-15','[0.41624921945334875, 0.7943609327220645, 0.2305392033266452, 0.003126127180805482, 0.08258790143798625]',x'67255f572156'),('2010-04-12','[0.7426240813483267, 0.17460982411968, 0.5062606612544903, 0.8641725521049805, 0.9093439280689491]',x'4557'),('2010-07-01','[0.9644470375249405, 0.14310028546123896, 0.30118256015842687, 0.12793715319326038]',x'6b7279692374524d306955'),('2012-03-29','[0.3808266319303118, 0.7975392670993785, 0.9125172409606002]',x'29'),('2012-08-24','[0.2368334281622129, 0.42370258940822, 0.09738052754248587, 0.6459847041878707]',x'255864432531546d443d263357557665'),('2013-10-14','[0.6366359320820038, 0.5258960185446601, 0.005468600014788019, 0.19002172571117618, 0.797860044965581]',x'58'),('2014-09-11','[0.26022068165495205]',x'6367665a373d53435e'),('2014-12-13','[0.18800960481374288]',x'692a5e4a727a2a41617574427a55406d'),('2016-03-01','[0.25353352722827344, 0.4696086393527653]',x'61'),('2018-12-24','[0.8883173845659126, 0.18078860876275404, 0.782658946181266, 0.2313310335729729]',x'77685f6b2869412a362b51'),('2021-06-26','[0.7528824657017837, 0.5179168006354101]',x'754a5e426f5a'),('2024-09-14','[0.785269452318795, 0.17609269926690957]',x'78252d2a362b4970353d5344584b766a633676'),('2024-12-30','[0.00042683533117783784, 0.26595214790312577, 0.48558040788839835, 0.7869280150674137]',x'6b67723d515756'),('2026-09-06','[0.9365758574340017, 0.035546493857794695, 0.7754058903482861, 0.06044405480634493]',x'77682b6f25313955643539795a345a'),('2027-05-19','[0.8578090694848647]',x'242b766b2d77'),('2027-11-01','[0.24985659225233242, 0.30331796357453394, 0.7477630696060984, 0.2642551752530038]',x'43375f5e6f6a62'),('2029-08-02','[0.7763676611291416]',x'4d6f'),('2030-02-05','[0.009232987106033366, 0.00424470502234362, 0.2340937202479449, 0.796532430692608]',x'793769216c4345516953292b246f4a796a756d'),('2031-11-05','[0.3856369365849062, 0.5724653509287152, 0.10591783536660329, 0.9541071017537033, 0.40942237293930245]',x'2373472b5225524e6141'),('2033-04-19','[0.47756023582738844, 0.591267913674284, 0.8929064352436822]',x'49574372366e'),('2034-06-15','[0.02368921979891078, 0.3785450156472247, 0.7560160881159008]',x'37'),('2035-05-04','[0.9173342769673862, 0.09009465925826006, 0.42919053504258686, 0.9562530025069383]',x'7e5e2645487e563d615944363571413831'),('2036-08-13','[0.618229016298302]',x'6c50396b64334950624343545a716e'); +SELECT `t1`.`col_44`, col_45 FROM `t1` WHERE NOT (`t1`.`col_44` BETWEEN '1980-03-18' AND '2011-10-24') GROUP BY `t1`.`col_46`,`t1`.`col_45` HAVING JSON_CONTAINS(`t1`.`col_45`, '0.540018481999012') OR JSON_OVERLAPS(`t1`.`col_45`, '[0.5785147169732324,0.8314968898215304,0.5226516826882698]'); +col_44 col_45 +EXPLAIN format=brief SELECT /*+ use_index_merge(t1) */ `t1`.`col_44`, col_45 FROM `t1` WHERE NOT (`t1`.`col_44` BETWEEN '1980-03-18' AND '2011-10-24') GROUP BY `t1`.`col_46`,`t1`.`col_45` HAVING JSON_CONTAINS(`t1`.`col_45`, '0.540018481999012') OR JSON_OVERLAPS(`t1`.`col_45`, '[0.5785147169732324,0.8314968898215304,0.5226516826882698]'); +id estRows task access object operator info +Selection 31.95 root or(json_contains(planner__core__indexmerge_path.t1.col_45, cast(cast("0.540018481999012", json BINARY), json BINARY)), json_overlaps(planner__core__indexmerge_path.t1.col_45, cast(cast("[0.5785147169732324,0.8314968898215304,0.5226516826882698]", json BINARY), json BINARY))) +└─IndexMerge 26.59 root type: union + ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t1, index:idx_17(cast(`col_45` as double array)) range:[0.540018481999012,0.540018481999012], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t1, index:idx_17(cast(`col_45` as double array)) range:[0.5785147169732324,0.5785147169732324], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t1, index:idx_17(cast(`col_45` as double array)) range:[0.8314968898215304,0.8314968898215304], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t1, index:idx_17(cast(`col_45` as double array)) range:[0.5226516826882698,0.5226516826882698], keep order:false, stats:pseudo + └─Selection(Probe) 26.59 cop[tikv] or(lt(planner__core__indexmerge_path.t1.col_44, 1980-03-18 00:00:00.000000), gt(planner__core__indexmerge_path.t1.col_44, 2011-10-24 00:00:00.000000)) + └─TableRowIDScan 39.94 cop[tikv] table:t1 keep order:false, stats:pseudo diff --git a/tests/integrationtest/t/planner/core/indexmerge_path.test b/tests/integrationtest/t/planner/core/indexmerge_path.test index f0d1d58cb6dcf..9dc8e02564ca4 100644 --- a/tests/integrationtest/t/planner/core/indexmerge_path.test +++ b/tests/integrationtest/t/planner/core/indexmerge_path.test @@ -393,3 +393,19 @@ INSERT INTO `t` VALUES('[12474495489656359869, 14407883655486982855, 42211846364 EXPLAIN SELECT /*+ use_index_merge(t)*/ MIN(col_37) FROM t WHERE col_38 BETWEEN '1984-12-13' AND '1975-01-28' OR JSON_CONTAINS(col_37, '138480458355390957') GROUP BY col_38 HAVING col_38 != '1988-03-22'; SELECT /*+ use_index_merge(t)*/ MIN(col_37) FROM t WHERE col_38 BETWEEN '1984-12-13' AND '1975-01-28' OR JSON_CONTAINS(col_37, '138480458355390957') GROUP BY col_38 HAVING col_38 != '1988-03-22'; + +# TestIssue52609 +drop table if exists t1; +CREATE TABLE `t1` ( + `col_44` date NOT NULL, + `col_45` json DEFAULT NULL, + `col_46` blob NOT NULL, + PRIMARY KEY (`col_44`) /*T![clustered_index] CLUSTERED */, + UNIQUE KEY `idx_16` (`col_46`(3)), + KEY `idx_17` ((cast(`col_45` as double array))) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; +INSERT INTO `t1` VALUES('1970-06-23','[0.4560478695486992, 0.803651626010387]',x'7536255340506e4c33316848237a35'),('1970-09-25','[0.15199642284684986, 0.6321478001858613, 0.7656785642600782]',x'46257656295764673d4d2879486a7064'),('1970-12-20','[0.1945757596453029, 0.805924917565015, 0.9514989635078432]',x'3237585f587937596440666c'),('1971-01-30','[0.8674221724194489, 0.5874297776348085, 0.953305932613583, 0.3597865188732217, 0.9685946450023771]',x'776435472d306a'),('1971-04-19','[0.3962760654250889, 0.3033630486210956, 0.5788307700170308, 0.45967119199449186, 0.18040912218010932]',x'5f6e595446'),('1971-07-13','[0.5430757366310748, 0.8018899907743144, 0.8380302518531714, 0.13858586403286638]',x'4c2a4a4f71402d476b61796e7975426859'),('1971-09-08','[0.5866539910043066, 0.47465227377222047, 0.3412140234543155, 0.8109510241444171, 0.7217020139220653]',x'21326e4240524d626451467226624d36473264'),('1974-03-11','[0.9692492406521573]',x'7625754e5e55'),('1974-06-21','[0.8026878685767292]',x'7233744b2340285f'),('1975-06-08','[0.9922869004082567, 0.13102472710817054, 0.6557189141392675, 0.7616974552959114, 0.9653986970900055]',x'384261614d'),('1977-10-19','[0.33915755092357786, 0.612813632848902, 0.31310578556186824, 0.7695374222593716, 0.6996560322741089]',x'436d37594d7529734e412d513339'),('1978-01-31','[0.9327357034423996, 0.5066011929178722, 0.35172580278260285]',x'5f2145376d3742284254726971374f6d62'),('1978-08-23','[0.05090948016614748]',x'42485a4e322d2444'),('1980-03-16','[0.49342945147794093, 0.3032388374311525, 0.7358262102414459, 0.28035992762300044, 0.9099270917809736]',x'244863456e506b4024366e7a5f4a4a4645'),('1981-11-13','[0.014281917443517428, 0.31751875796372186, 0.5653893294127147, 0.6252442676826157, 0.6354719008300445]',x'4959463d2d6359796e377854754d2470'),('1983-10-16','[0.6992056327393458, 0.6285491992936737]',x'5175714844556626514743434b7543314249'),('1984-04-16','[0.5253196030542662, 0.3561411260568334, 0.7687615143503639, 0.4271982783883207, 0.20382816433225448]',x'475176'),('1988-07-19','[0.9233398239291353, 0.9396459773262974, 0.540018481999012, 0.181978533893545]',x'652539286c5f7e6b482a7265575a'),('1988-08-27','[0.9206220563718938]',x'475f693338392b646847'),('1989-12-07','[0.7964395106523453, 0.15227139590401054, 0.008643835436697868, 0.49470337240413564, 0.421379488694248]',x'377a767a65517647364856'),('1994-09-19','[0.19716919785297451]',x'3d26'),('1994-10-09',NULL,x'2a475463505136376861'),('1997-01-28','[0.30777386345347096]',x'70335e5e506b34236231476c35465e5e6d7448'),('2003-03-20','[0.23787267537350917, 0.5250550691578201, 0.9997853645717626]',x'404925286e5e726b305e'),('2004-04-12','[0.5368094270222808, 0.5306352503604773]',x'3752686b497448347039462136405a4f7a32'),('2005-02-04','[0.6531851579067487, 0.43849173297844984]',x'7e472a33336e73374558386a47234d5578'),('2005-02-18','[0.6303813789290023, 0.8178417890758697, 0.5354859968496037, 0.8868549026347942, 0.7253817513425349]',x'7e2d426a566329774a566c24217729797824'),('2005-05-09','[0.4155497358943851, 0.7649690762144056, 0.08552617826430448, 0.8054846042993035, 0.40076060531272734]',x''),('2006-02-10','[0.0506631513523112]',x'54416c7752526b55695258'),('2006-05-28','[0.7391997763354717, 0.43722943543743453, 0.8497153956761379, 0.8287059733052305, 0.8111927284482152]',x'38306635334126614d3455717e6b5762'),('2006-12-11','[0.11237614634576035, 0.33642094098687275]',x'57'),('2008-11-15','[0.41624921945334875, 0.7943609327220645, 0.2305392033266452, 0.003126127180805482, 0.08258790143798625]',x'67255f572156'),('2010-04-12','[0.7426240813483267, 0.17460982411968, 0.5062606612544903, 0.8641725521049805, 0.9093439280689491]',x'4557'),('2010-07-01','[0.9644470375249405, 0.14310028546123896, 0.30118256015842687, 0.12793715319326038]',x'6b7279692374524d306955'),('2012-03-29','[0.3808266319303118, 0.7975392670993785, 0.9125172409606002]',x'29'),('2012-08-24','[0.2368334281622129, 0.42370258940822, 0.09738052754248587, 0.6459847041878707]',x'255864432531546d443d263357557665'),('2013-10-14','[0.6366359320820038, 0.5258960185446601, 0.005468600014788019, 0.19002172571117618, 0.797860044965581]',x'58'),('2014-09-11','[0.26022068165495205]',x'6367665a373d53435e'),('2014-12-13','[0.18800960481374288]',x'692a5e4a727a2a41617574427a55406d'),('2016-03-01','[0.25353352722827344, 0.4696086393527653]',x'61'),('2018-12-24','[0.8883173845659126, 0.18078860876275404, 0.782658946181266, 0.2313310335729729]',x'77685f6b2869412a362b51'),('2021-06-26','[0.7528824657017837, 0.5179168006354101]',x'754a5e426f5a'),('2024-09-14','[0.785269452318795, 0.17609269926690957]',x'78252d2a362b4970353d5344584b766a633676'),('2024-12-30','[0.00042683533117783784, 0.26595214790312577, 0.48558040788839835, 0.7869280150674137]',x'6b67723d515756'),('2026-09-06','[0.9365758574340017, 0.035546493857794695, 0.7754058903482861, 0.06044405480634493]',x'77682b6f25313955643539795a345a'),('2027-05-19','[0.8578090694848647]',x'242b766b2d77'),('2027-11-01','[0.24985659225233242, 0.30331796357453394, 0.7477630696060984, 0.2642551752530038]',x'43375f5e6f6a62'),('2029-08-02','[0.7763676611291416]',x'4d6f'),('2030-02-05','[0.009232987106033366, 0.00424470502234362, 0.2340937202479449, 0.796532430692608]',x'793769216c4345516953292b246f4a796a756d'),('2031-11-05','[0.3856369365849062, 0.5724653509287152, 0.10591783536660329, 0.9541071017537033, 0.40942237293930245]',x'2373472b5225524e6141'),('2033-04-19','[0.47756023582738844, 0.591267913674284, 0.8929064352436822]',x'49574372366e'),('2034-06-15','[0.02368921979891078, 0.3785450156472247, 0.7560160881159008]',x'37'),('2035-05-04','[0.9173342769673862, 0.09009465925826006, 0.42919053504258686, 0.9562530025069383]',x'7e5e2645487e563d615944363571413831'),('2036-08-13','[0.618229016298302]',x'6c50396b64334950624343545a716e'); + +SELECT `t1`.`col_44`, col_45 FROM `t1` WHERE NOT (`t1`.`col_44` BETWEEN '1980-03-18' AND '2011-10-24') GROUP BY `t1`.`col_46`,`t1`.`col_45` HAVING JSON_CONTAINS(`t1`.`col_45`, '0.540018481999012') OR JSON_OVERLAPS(`t1`.`col_45`, '[0.5785147169732324,0.8314968898215304,0.5226516826882698]'); + +EXPLAIN format=brief SELECT /*+ use_index_merge(t1) */ `t1`.`col_44`, col_45 FROM `t1` WHERE NOT (`t1`.`col_44` BETWEEN '1980-03-18' AND '2011-10-24') GROUP BY `t1`.`col_46`,`t1`.`col_45` HAVING JSON_CONTAINS(`t1`.`col_45`, '0.540018481999012') OR JSON_OVERLAPS(`t1`.`col_45`, '[0.5785147169732324,0.8314968898215304,0.5226516826882698]'); From 0907354200824bb2c2ffa8d3e6cbc7fba4d9936c Mon Sep 17 00:00:00 2001 From: time-and-fate <25057648+time-and-fate@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:11:47 +0800 Subject: [PATCH 2/2] simplify test case --- .../integrationtest/r/planner/core/indexmerge_path.result | 6 +++--- tests/integrationtest/t/planner/core/indexmerge_path.test | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/integrationtest/r/planner/core/indexmerge_path.result b/tests/integrationtest/r/planner/core/indexmerge_path.result index 404bee7b1a953..e3dd09f1a19eb 100644 --- a/tests/integrationtest/r/planner/core/indexmerge_path.result +++ b/tests/integrationtest/r/planner/core/indexmerge_path.result @@ -972,10 +972,10 @@ PRIMARY KEY (`col_44`) /*T![clustered_index] CLUSTERED */, UNIQUE KEY `idx_16` (`col_46`(3)), KEY `idx_17` ((cast(`col_45` as double array))) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; -INSERT INTO `t1` VALUES('1970-06-23','[0.4560478695486992, 0.803651626010387]',x'7536255340506e4c33316848237a35'),('1970-09-25','[0.15199642284684986, 0.6321478001858613, 0.7656785642600782]',x'46257656295764673d4d2879486a7064'),('1970-12-20','[0.1945757596453029, 0.805924917565015, 0.9514989635078432]',x'3237585f587937596440666c'),('1971-01-30','[0.8674221724194489, 0.5874297776348085, 0.953305932613583, 0.3597865188732217, 0.9685946450023771]',x'776435472d306a'),('1971-04-19','[0.3962760654250889, 0.3033630486210956, 0.5788307700170308, 0.45967119199449186, 0.18040912218010932]',x'5f6e595446'),('1971-07-13','[0.5430757366310748, 0.8018899907743144, 0.8380302518531714, 0.13858586403286638]',x'4c2a4a4f71402d476b61796e7975426859'),('1971-09-08','[0.5866539910043066, 0.47465227377222047, 0.3412140234543155, 0.8109510241444171, 0.7217020139220653]',x'21326e4240524d626451467226624d36473264'),('1974-03-11','[0.9692492406521573]',x'7625754e5e55'),('1974-06-21','[0.8026878685767292]',x'7233744b2340285f'),('1975-06-08','[0.9922869004082567, 0.13102472710817054, 0.6557189141392675, 0.7616974552959114, 0.9653986970900055]',x'384261614d'),('1977-10-19','[0.33915755092357786, 0.612813632848902, 0.31310578556186824, 0.7695374222593716, 0.6996560322741089]',x'436d37594d7529734e412d513339'),('1978-01-31','[0.9327357034423996, 0.5066011929178722, 0.35172580278260285]',x'5f2145376d3742284254726971374f6d62'),('1978-08-23','[0.05090948016614748]',x'42485a4e322d2444'),('1980-03-16','[0.49342945147794093, 0.3032388374311525, 0.7358262102414459, 0.28035992762300044, 0.9099270917809736]',x'244863456e506b4024366e7a5f4a4a4645'),('1981-11-13','[0.014281917443517428, 0.31751875796372186, 0.5653893294127147, 0.6252442676826157, 0.6354719008300445]',x'4959463d2d6359796e377854754d2470'),('1983-10-16','[0.6992056327393458, 0.6285491992936737]',x'5175714844556626514743434b7543314249'),('1984-04-16','[0.5253196030542662, 0.3561411260568334, 0.7687615143503639, 0.4271982783883207, 0.20382816433225448]',x'475176'),('1988-07-19','[0.9233398239291353, 0.9396459773262974, 0.540018481999012, 0.181978533893545]',x'652539286c5f7e6b482a7265575a'),('1988-08-27','[0.9206220563718938]',x'475f693338392b646847'),('1989-12-07','[0.7964395106523453, 0.15227139590401054, 0.008643835436697868, 0.49470337240413564, 0.421379488694248]',x'377a767a65517647364856'),('1994-09-19','[0.19716919785297451]',x'3d26'),('1994-10-09',NULL,x'2a475463505136376861'),('1997-01-28','[0.30777386345347096]',x'70335e5e506b34236231476c35465e5e6d7448'),('2003-03-20','[0.23787267537350917, 0.5250550691578201, 0.9997853645717626]',x'404925286e5e726b305e'),('2004-04-12','[0.5368094270222808, 0.5306352503604773]',x'3752686b497448347039462136405a4f7a32'),('2005-02-04','[0.6531851579067487, 0.43849173297844984]',x'7e472a33336e73374558386a47234d5578'),('2005-02-18','[0.6303813789290023, 0.8178417890758697, 0.5354859968496037, 0.8868549026347942, 0.7253817513425349]',x'7e2d426a566329774a566c24217729797824'),('2005-05-09','[0.4155497358943851, 0.7649690762144056, 0.08552617826430448, 0.8054846042993035, 0.40076060531272734]',x''),('2006-02-10','[0.0506631513523112]',x'54416c7752526b55695258'),('2006-05-28','[0.7391997763354717, 0.43722943543743453, 0.8497153956761379, 0.8287059733052305, 0.8111927284482152]',x'38306635334126614d3455717e6b5762'),('2006-12-11','[0.11237614634576035, 0.33642094098687275]',x'57'),('2008-11-15','[0.41624921945334875, 0.7943609327220645, 0.2305392033266452, 0.003126127180805482, 0.08258790143798625]',x'67255f572156'),('2010-04-12','[0.7426240813483267, 0.17460982411968, 0.5062606612544903, 0.8641725521049805, 0.9093439280689491]',x'4557'),('2010-07-01','[0.9644470375249405, 0.14310028546123896, 0.30118256015842687, 0.12793715319326038]',x'6b7279692374524d306955'),('2012-03-29','[0.3808266319303118, 0.7975392670993785, 0.9125172409606002]',x'29'),('2012-08-24','[0.2368334281622129, 0.42370258940822, 0.09738052754248587, 0.6459847041878707]',x'255864432531546d443d263357557665'),('2013-10-14','[0.6366359320820038, 0.5258960185446601, 0.005468600014788019, 0.19002172571117618, 0.797860044965581]',x'58'),('2014-09-11','[0.26022068165495205]',x'6367665a373d53435e'),('2014-12-13','[0.18800960481374288]',x'692a5e4a727a2a41617574427a55406d'),('2016-03-01','[0.25353352722827344, 0.4696086393527653]',x'61'),('2018-12-24','[0.8883173845659126, 0.18078860876275404, 0.782658946181266, 0.2313310335729729]',x'77685f6b2869412a362b51'),('2021-06-26','[0.7528824657017837, 0.5179168006354101]',x'754a5e426f5a'),('2024-09-14','[0.785269452318795, 0.17609269926690957]',x'78252d2a362b4970353d5344584b766a633676'),('2024-12-30','[0.00042683533117783784, 0.26595214790312577, 0.48558040788839835, 0.7869280150674137]',x'6b67723d515756'),('2026-09-06','[0.9365758574340017, 0.035546493857794695, 0.7754058903482861, 0.06044405480634493]',x'77682b6f25313955643539795a345a'),('2027-05-19','[0.8578090694848647]',x'242b766b2d77'),('2027-11-01','[0.24985659225233242, 0.30331796357453394, 0.7477630696060984, 0.2642551752530038]',x'43375f5e6f6a62'),('2029-08-02','[0.7763676611291416]',x'4d6f'),('2030-02-05','[0.009232987106033366, 0.00424470502234362, 0.2340937202479449, 0.796532430692608]',x'793769216c4345516953292b246f4a796a756d'),('2031-11-05','[0.3856369365849062, 0.5724653509287152, 0.10591783536660329, 0.9541071017537033, 0.40942237293930245]',x'2373472b5225524e6141'),('2033-04-19','[0.47756023582738844, 0.591267913674284, 0.8929064352436822]',x'49574372366e'),('2034-06-15','[0.02368921979891078, 0.3785450156472247, 0.7560160881159008]',x'37'),('2035-05-04','[0.9173342769673862, 0.09009465925826006, 0.42919053504258686, 0.9562530025069383]',x'7e5e2645487e563d615944363571413831'),('2036-08-13','[0.618229016298302]',x'6c50396b64334950624343545a716e'); -SELECT `t1`.`col_44`, col_45 FROM `t1` WHERE NOT (`t1`.`col_44` BETWEEN '1980-03-18' AND '2011-10-24') GROUP BY `t1`.`col_46`,`t1`.`col_45` HAVING JSON_CONTAINS(`t1`.`col_45`, '0.540018481999012') OR JSON_OVERLAPS(`t1`.`col_45`, '[0.5785147169732324,0.8314968898215304,0.5226516826882698]'); +INSERT INTO t1 VALUES('1988-07-19','[0.9233398239291353, 0.9396459773262974, 0.540018481999012, 0.181978533893545]',x'652539286c5f7e6b482a7265575a'); +SELECT col_44, col_45 FROM t1 WHERE NOT (col_44 BETWEEN '1980-03-18' AND '2011-10-24') GROUP BY col_46,col_45 HAVING JSON_CONTAINS(col_45, '0.540018481999012') OR JSON_OVERLAPS(col_45, '[0.5785147169732324,0.8314968898215304,0.5226516826882698]'); col_44 col_45 -EXPLAIN format=brief SELECT /*+ use_index_merge(t1) */ `t1`.`col_44`, col_45 FROM `t1` WHERE NOT (`t1`.`col_44` BETWEEN '1980-03-18' AND '2011-10-24') GROUP BY `t1`.`col_46`,`t1`.`col_45` HAVING JSON_CONTAINS(`t1`.`col_45`, '0.540018481999012') OR JSON_OVERLAPS(`t1`.`col_45`, '[0.5785147169732324,0.8314968898215304,0.5226516826882698]'); +EXPLAIN format=brief SELECT /*+ use_index_merge(t1) */ col_44, col_45 FROM t1 WHERE NOT (col_44 BETWEEN '1980-03-18' AND '2011-10-24') GROUP BY col_46,col_45 HAVING JSON_CONTAINS(col_45, '0.540018481999012') OR JSON_OVERLAPS(col_45, '[0.5785147169732324,0.8314968898215304,0.5226516826882698]'); id estRows task access object operator info Selection 31.95 root or(json_contains(planner__core__indexmerge_path.t1.col_45, cast(cast("0.540018481999012", json BINARY), json BINARY)), json_overlaps(planner__core__indexmerge_path.t1.col_45, cast(cast("[0.5785147169732324,0.8314968898215304,0.5226516826882698]", json BINARY), json BINARY))) └─IndexMerge 26.59 root type: union diff --git a/tests/integrationtest/t/planner/core/indexmerge_path.test b/tests/integrationtest/t/planner/core/indexmerge_path.test index 9dc8e02564ca4..52fa5cf5cb249 100644 --- a/tests/integrationtest/t/planner/core/indexmerge_path.test +++ b/tests/integrationtest/t/planner/core/indexmerge_path.test @@ -404,8 +404,6 @@ CREATE TABLE `t1` ( UNIQUE KEY `idx_16` (`col_46`(3)), KEY `idx_17` ((cast(`col_45` as double array))) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; -INSERT INTO `t1` VALUES('1970-06-23','[0.4560478695486992, 0.803651626010387]',x'7536255340506e4c33316848237a35'),('1970-09-25','[0.15199642284684986, 0.6321478001858613, 0.7656785642600782]',x'46257656295764673d4d2879486a7064'),('1970-12-20','[0.1945757596453029, 0.805924917565015, 0.9514989635078432]',x'3237585f587937596440666c'),('1971-01-30','[0.8674221724194489, 0.5874297776348085, 0.953305932613583, 0.3597865188732217, 0.9685946450023771]',x'776435472d306a'),('1971-04-19','[0.3962760654250889, 0.3033630486210956, 0.5788307700170308, 0.45967119199449186, 0.18040912218010932]',x'5f6e595446'),('1971-07-13','[0.5430757366310748, 0.8018899907743144, 0.8380302518531714, 0.13858586403286638]',x'4c2a4a4f71402d476b61796e7975426859'),('1971-09-08','[0.5866539910043066, 0.47465227377222047, 0.3412140234543155, 0.8109510241444171, 0.7217020139220653]',x'21326e4240524d626451467226624d36473264'),('1974-03-11','[0.9692492406521573]',x'7625754e5e55'),('1974-06-21','[0.8026878685767292]',x'7233744b2340285f'),('1975-06-08','[0.9922869004082567, 0.13102472710817054, 0.6557189141392675, 0.7616974552959114, 0.9653986970900055]',x'384261614d'),('1977-10-19','[0.33915755092357786, 0.612813632848902, 0.31310578556186824, 0.7695374222593716, 0.6996560322741089]',x'436d37594d7529734e412d513339'),('1978-01-31','[0.9327357034423996, 0.5066011929178722, 0.35172580278260285]',x'5f2145376d3742284254726971374f6d62'),('1978-08-23','[0.05090948016614748]',x'42485a4e322d2444'),('1980-03-16','[0.49342945147794093, 0.3032388374311525, 0.7358262102414459, 0.28035992762300044, 0.9099270917809736]',x'244863456e506b4024366e7a5f4a4a4645'),('1981-11-13','[0.014281917443517428, 0.31751875796372186, 0.5653893294127147, 0.6252442676826157, 0.6354719008300445]',x'4959463d2d6359796e377854754d2470'),('1983-10-16','[0.6992056327393458, 0.6285491992936737]',x'5175714844556626514743434b7543314249'),('1984-04-16','[0.5253196030542662, 0.3561411260568334, 0.7687615143503639, 0.4271982783883207, 0.20382816433225448]',x'475176'),('1988-07-19','[0.9233398239291353, 0.9396459773262974, 0.540018481999012, 0.181978533893545]',x'652539286c5f7e6b482a7265575a'),('1988-08-27','[0.9206220563718938]',x'475f693338392b646847'),('1989-12-07','[0.7964395106523453, 0.15227139590401054, 0.008643835436697868, 0.49470337240413564, 0.421379488694248]',x'377a767a65517647364856'),('1994-09-19','[0.19716919785297451]',x'3d26'),('1994-10-09',NULL,x'2a475463505136376861'),('1997-01-28','[0.30777386345347096]',x'70335e5e506b34236231476c35465e5e6d7448'),('2003-03-20','[0.23787267537350917, 0.5250550691578201, 0.9997853645717626]',x'404925286e5e726b305e'),('2004-04-12','[0.5368094270222808, 0.5306352503604773]',x'3752686b497448347039462136405a4f7a32'),('2005-02-04','[0.6531851579067487, 0.43849173297844984]',x'7e472a33336e73374558386a47234d5578'),('2005-02-18','[0.6303813789290023, 0.8178417890758697, 0.5354859968496037, 0.8868549026347942, 0.7253817513425349]',x'7e2d426a566329774a566c24217729797824'),('2005-05-09','[0.4155497358943851, 0.7649690762144056, 0.08552617826430448, 0.8054846042993035, 0.40076060531272734]',x''),('2006-02-10','[0.0506631513523112]',x'54416c7752526b55695258'),('2006-05-28','[0.7391997763354717, 0.43722943543743453, 0.8497153956761379, 0.8287059733052305, 0.8111927284482152]',x'38306635334126614d3455717e6b5762'),('2006-12-11','[0.11237614634576035, 0.33642094098687275]',x'57'),('2008-11-15','[0.41624921945334875, 0.7943609327220645, 0.2305392033266452, 0.003126127180805482, 0.08258790143798625]',x'67255f572156'),('2010-04-12','[0.7426240813483267, 0.17460982411968, 0.5062606612544903, 0.8641725521049805, 0.9093439280689491]',x'4557'),('2010-07-01','[0.9644470375249405, 0.14310028546123896, 0.30118256015842687, 0.12793715319326038]',x'6b7279692374524d306955'),('2012-03-29','[0.3808266319303118, 0.7975392670993785, 0.9125172409606002]',x'29'),('2012-08-24','[0.2368334281622129, 0.42370258940822, 0.09738052754248587, 0.6459847041878707]',x'255864432531546d443d263357557665'),('2013-10-14','[0.6366359320820038, 0.5258960185446601, 0.005468600014788019, 0.19002172571117618, 0.797860044965581]',x'58'),('2014-09-11','[0.26022068165495205]',x'6367665a373d53435e'),('2014-12-13','[0.18800960481374288]',x'692a5e4a727a2a41617574427a55406d'),('2016-03-01','[0.25353352722827344, 0.4696086393527653]',x'61'),('2018-12-24','[0.8883173845659126, 0.18078860876275404, 0.782658946181266, 0.2313310335729729]',x'77685f6b2869412a362b51'),('2021-06-26','[0.7528824657017837, 0.5179168006354101]',x'754a5e426f5a'),('2024-09-14','[0.785269452318795, 0.17609269926690957]',x'78252d2a362b4970353d5344584b766a633676'),('2024-12-30','[0.00042683533117783784, 0.26595214790312577, 0.48558040788839835, 0.7869280150674137]',x'6b67723d515756'),('2026-09-06','[0.9365758574340017, 0.035546493857794695, 0.7754058903482861, 0.06044405480634493]',x'77682b6f25313955643539795a345a'),('2027-05-19','[0.8578090694848647]',x'242b766b2d77'),('2027-11-01','[0.24985659225233242, 0.30331796357453394, 0.7477630696060984, 0.2642551752530038]',x'43375f5e6f6a62'),('2029-08-02','[0.7763676611291416]',x'4d6f'),('2030-02-05','[0.009232987106033366, 0.00424470502234362, 0.2340937202479449, 0.796532430692608]',x'793769216c4345516953292b246f4a796a756d'),('2031-11-05','[0.3856369365849062, 0.5724653509287152, 0.10591783536660329, 0.9541071017537033, 0.40942237293930245]',x'2373472b5225524e6141'),('2033-04-19','[0.47756023582738844, 0.591267913674284, 0.8929064352436822]',x'49574372366e'),('2034-06-15','[0.02368921979891078, 0.3785450156472247, 0.7560160881159008]',x'37'),('2035-05-04','[0.9173342769673862, 0.09009465925826006, 0.42919053504258686, 0.9562530025069383]',x'7e5e2645487e563d615944363571413831'),('2036-08-13','[0.618229016298302]',x'6c50396b64334950624343545a716e'); - -SELECT `t1`.`col_44`, col_45 FROM `t1` WHERE NOT (`t1`.`col_44` BETWEEN '1980-03-18' AND '2011-10-24') GROUP BY `t1`.`col_46`,`t1`.`col_45` HAVING JSON_CONTAINS(`t1`.`col_45`, '0.540018481999012') OR JSON_OVERLAPS(`t1`.`col_45`, '[0.5785147169732324,0.8314968898215304,0.5226516826882698]'); - -EXPLAIN format=brief SELECT /*+ use_index_merge(t1) */ `t1`.`col_44`, col_45 FROM `t1` WHERE NOT (`t1`.`col_44` BETWEEN '1980-03-18' AND '2011-10-24') GROUP BY `t1`.`col_46`,`t1`.`col_45` HAVING JSON_CONTAINS(`t1`.`col_45`, '0.540018481999012') OR JSON_OVERLAPS(`t1`.`col_45`, '[0.5785147169732324,0.8314968898215304,0.5226516826882698]'); +INSERT INTO t1 VALUES('1988-07-19','[0.9233398239291353, 0.9396459773262974, 0.540018481999012, 0.181978533893545]',x'652539286c5f7e6b482a7265575a'); +SELECT col_44, col_45 FROM t1 WHERE NOT (col_44 BETWEEN '1980-03-18' AND '2011-10-24') GROUP BY col_46,col_45 HAVING JSON_CONTAINS(col_45, '0.540018481999012') OR JSON_OVERLAPS(col_45, '[0.5785147169732324,0.8314968898215304,0.5226516826882698]'); +EXPLAIN format=brief SELECT /*+ use_index_merge(t1) */ col_44, col_45 FROM t1 WHERE NOT (col_44 BETWEEN '1980-03-18' AND '2011-10-24') GROUP BY col_46,col_45 HAVING JSON_CONTAINS(col_45, '0.540018481999012') OR JSON_OVERLAPS(col_45, '[0.5785147169732324,0.8314968898215304,0.5226516826882698]');