Set to critical, because in 11.0 JSON_HB is planned to become a default value, so it will become a regression. At least its extent needs to be analyzed.
CREATE DATABASE dbt3;
|
USE dbt3;
|
|
set default_storage_engine=Aria;
|
|
--source include/dbt3_s001.inc
|
|
ANALYZE TABLE part, partsupp, supplier, lineitem, orders, customer PERSISTENT FOR ALL;
|
|
--start_timer
|
SELECT COUNT(*) AS cnt FROM part LEFT JOIN partsupp ON ( p_partkey = ps_partkey ) JOIN supplier ON (s_suppkey = ps_suppkey) LEFT JOIN lineitem ON ( ps_suppkey = l_suppkey ) JOIN orders ON ( l_orderkey = o_orderkey ) JOIN customer ON ( o_custkey = c_custkey ) WHERE ps_partkey < 130 AND ps_comment IS NOT NULL HAVING cnt < 0;
|
--end_timer
|
|
EXPLAIN EXTENDED
|
SELECT COUNT(*) AS cnt FROM part LEFT JOIN partsupp ON ( p_partkey = ps_partkey ) JOIN supplier ON (s_suppkey = ps_suppkey) LEFT JOIN lineitem ON ( ps_suppkey = l_suppkey ) JOIN orders ON ( l_orderkey = o_orderkey ) JOIN customer ON ( o_custkey = c_custkey ) WHERE ps_partkey < 130 AND ps_comment IS NOT NULL HAVING cnt < 0;
|
|
DROP DATABASE dbt3;
|
With DOUBLE_PREC_HB, the query takes 0.14 sec on my machine, on 10.8.6 release build. With JSON_HB it is 1.8 sec.
Plans:
10.8.6 with DOUBLE_PREC_HB
|
+------+-------------+----------+--------+--------------------------------------------------------+-------------+---------+---------------------------------------------+------+----------+--------------------------------------------------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|
+------+-------------+----------+--------+--------------------------------------------------------+-------------+---------+---------------------------------------------+------+----------+--------------------------------------------------------------+
|
| 1 | SIMPLE | supplier | index | PRIMARY | PRIMARY | 4 | NULL | 10 | 100.00 | Using index |
|
| 1 | SIMPLE | lineitem | ref | PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity | i_l_suppkey | 5 | test.supplier.s_suppkey | 600 | 100.00 | |
|
| 1 | SIMPLE | orders | eq_ref | PRIMARY,i_o_custkey | PRIMARY | 4 | test.lineitem.l_orderkey | 1 | 100.00 | Using where |
|
| 1 | SIMPLE | customer | eq_ref | PRIMARY | PRIMARY | 4 | test.orders.o_custkey | 1 | 100.00 | Using index |
|
| 1 | SIMPLE | part | range | PRIMARY | PRIMARY | 4 | NULL | 129 | 100.00 | Using where; Using index; Using join buffer (flat, BNL join) |
|
| 1 | SIMPLE | partsupp | eq_ref | PRIMARY,i_ps_partkey,i_ps_suppkey | PRIMARY | 8 | test.part.p_partkey,test.supplier.s_suppkey | 1 | 99.22 | Using where |
|
+------+-------------+----------+--------+--------------------------------------------------------+-------------+---------+---------------------------------------------+------+----------+--------------------------------------------------------------+
|
| Note | 1003 | select count(0) AS `cnt` from `test`.`part` join `test`.`partsupp` join `test`.`supplier` join `test`.`lineitem` join `test`.`orders` join `test`.`customer` where `test`.`customer`.`c_custkey` = `test`.`orders`.`o_custkey` and `test`.`orders`.`o_orderkey` = `test`.`lineitem`.`l_orderkey` and `test`.`lineitem`.`l_suppkey` = `test`.`supplier`.`s_suppkey` and `test`.`partsupp`.`ps_suppkey` = `test`.`supplier`.`s_suppkey` and `test`.`partsupp`.`ps_partkey` = `test`.`part`.`p_partkey` and `test`.`part`.`p_partkey` < 130 and `test`.`partsupp`.`ps_comment` is not null |
|
10.8.6 with JSON_HB
|
+------+-------------+----------+--------+--------------------------------------------------------+--------------+---------+--------------------------+------+----------+-------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|
+------+-------------+----------+--------+--------------------------------------------------------+--------------+---------+--------------------------+------+----------+-------------+
|
| 1 | SIMPLE | supplier | index | PRIMARY | PRIMARY | 4 | NULL | 10 | 100.00 | Using index |
|
| 1 | SIMPLE | partsupp | ref | PRIMARY,i_ps_partkey,i_ps_suppkey | i_ps_suppkey | 4 | test.supplier.s_suppkey | 70 | 40.00 | Using where |
|
| 1 | SIMPLE | part | eq_ref | PRIMARY | PRIMARY | 4 | test.partsupp.ps_partkey | 1 | 100.00 | Using index |
|
| 1 | SIMPLE | lineitem | ref | PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity | i_l_suppkey | 5 | test.supplier.s_suppkey | 600 | 100.00 | |
|
| 1 | SIMPLE | orders | eq_ref | PRIMARY,i_o_custkey | PRIMARY | 4 | test.lineitem.l_orderkey | 1 | 100.00 | Using where |
|
| 1 | SIMPLE | customer | eq_ref | PRIMARY | PRIMARY | 4 | test.orders.o_custkey | 1 | 100.00 | Using index |
|
+------+-------------+----------+--------+--------------------------------------------------------+--------------+---------+--------------------------+------+----------+-------------+
|
| Note | 1003 | select count(0) AS `cnt` from `test`.`part` join `test`.`partsupp` join `test`.`supplier` join `test`.`lineitem` join `test`.`orders` join `test`.`customer` where `test`.`customer`.`c_custkey` = `test`.`orders`.`o_custkey` and `test`.`orders`.`o_orderkey` = `test`.`lineitem`.`l_orderkey` and `test`.`partsupp`.`ps_suppkey` = `test`.`supplier`.`s_suppkey` and `test`.`lineitem`.`l_suppkey` = `test`.`supplier`.`s_suppkey` and `test`.`part`.`p_partkey` = `test`.`partsupp`.`ps_partkey` and `test`.`partsupp`.`ps_partkey` < 130 and `test`.`partsupp`.`ps_comment` is not null |
|
{"report":{"fcp":1726.1000003814697,"ttfb":344.80000019073486,"pageVisibility":"visible","entityId":118745,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"cc36f8ad-c4e1-4d91-9738-f1268b3a2a75","navigationType":0,"readyForUser":1843.3000001907349,"redirectCount":0,"resourceLoadedEnd":1384.5,"resourceLoadedStart":406.1000003814697,"resourceTiming":[{"duration":201.89999961853027,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":406.1000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":406.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":608,"responseStart":0,"secureConnectionStart":0},{"duration":202,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":406.40000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":406.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":608.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":797.5999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":406.7000002861023,"connectEnd":406.7000002861023,"connectStart":406.7000002861023,"domainLookupEnd":406.7000002861023,"domainLookupStart":406.7000002861023,"fetchStart":406.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":613.2000002861023,"responseEnd":1204.3000001907349,"responseStart":676.7000002861023,"secureConnectionStart":406.7000002861023},{"duration":960.9000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":406.90000009536743,"connectEnd":406.90000009536743,"connectStart":406.90000009536743,"domainLookupEnd":406.90000009536743,"domainLookupStart":406.90000009536743,"fetchStart":406.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":613.7000002861023,"responseEnd":1367.8000001907349,"responseStart":675.7000002861023,"secureConnectionStart":406.90000009536743},{"duration":281,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":407.1000003814697,"connectEnd":407.1000003814697,"connectStart":407.1000003814697,"domainLookupEnd":407.1000003814697,"domainLookupStart":407.1000003814697,"fetchStart":407.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":613.8000001907349,"responseEnd":688.1000003814697,"responseStart":679.8000001907349,"secureConnectionStart":407.1000003814697},{"duration":280.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":407.30000019073486,"connectEnd":407.30000019073486,"connectStart":407.30000019073486,"domainLookupEnd":407.30000019073486,"domainLookupStart":407.30000019073486,"fetchStart":407.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":613.9000000953674,"responseEnd":687.7000002861023,"responseStart":679.1000003814697,"secureConnectionStart":407.30000019073486},{"duration":280.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":407.5,"connectEnd":407.5,"connectStart":407.5,"domainLookupEnd":407.5,"domainLookupStart":407.5,"fetchStart":407.5,"redirectEnd":0,"redirectStart":0,"requestStart":614.4000000953674,"responseEnd":688.4000000953674,"responseStart":680.6000003814697,"secureConnectionStart":407.5},{"duration":200.7999997138977,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":407.7000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":407.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":608.5,"responseStart":0,"secureConnectionStart":0},{"duration":280.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":407.80000019073486,"connectEnd":407.80000019073486,"connectStart":407.80000019073486,"domainLookupEnd":407.80000019073486,"domainLookupStart":407.80000019073486,"fetchStart":407.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":614.5,"responseEnd":688.6000003814697,"responseStart":682.1000003814697,"secureConnectionStart":407.80000019073486},{"duration":201.80000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":408,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":408,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":609.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":283.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":408.1000003814697,"connectEnd":408.1000003814697,"connectStart":408.1000003814697,"domainLookupEnd":408.1000003814697,"domainLookupStart":408.1000003814697,"fetchStart":408.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":614.8000001907349,"responseEnd":691.8000001907349,"responseStart":683.1000003814697,"secureConnectionStart":408.1000003814697},{"duration":972.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":408.90000009536743,"connectEnd":408.90000009536743,"connectStart":408.90000009536743,"domainLookupEnd":408.90000009536743,"domainLookupStart":408.90000009536743,"fetchStart":408.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":792.6000003814697,"responseEnd":1381,"responseStart":1372.1000003814697,"secureConnectionStart":408.90000009536743},{"duration":975.5999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":408.90000009536743,"connectEnd":408.90000009536743,"connectStart":408.90000009536743,"domainLookupEnd":408.90000009536743,"domainLookupStart":408.90000009536743,"fetchStart":408.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":928.8000001907349,"responseEnd":1384.5,"responseStart":1374.7000002861023,"secureConnectionStart":408.90000009536743},{"duration":411.3999996185303,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1354.1000003814697,"connectEnd":1354.1000003814697,"connectStart":1354.1000003814697,"domainLookupEnd":1354.1000003814697,"domainLookupStart":1354.1000003814697,"fetchStart":1354.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":1730.9000000953674,"responseEnd":1765.5,"responseStart":1764.8000001907349,"secureConnectionStart":1354.1000003814697},{"duration":315.6000003814697,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1704.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1704.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2020.1000003814697,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":128,"responseStart":344,"responseEnd":351,"domLoading":378,"domInteractive":1944,"domContentLoadedEventStart":1944,"domContentLoadedEventEnd":2015,"domComplete":3134,"loadEventStart":3134,"loadEventEnd":3134,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1916},{"name":"bigPipe.sidebar-id.end","time":1916.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.start","time":1917},{"name":"bigPipe.activity-panel-pipe-id.end","time":1918.8000001907349},{"name":"activityTabFullyLoaded","time":2034}],"measures":[],"correlationId":"fe3a3404ab93ea","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":102,"dbReadsTimeInMs":11,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
On the current bb-11.0 tree, I get the same join order with JSON_HB and DOUBLE_PREC_HB.
It matches the join order that the report says 10.8 produces with JSON_HB:
+------+-------------+----------+--------+--------------------------------------------------------+--------------+---------+-----------------------------+------+----------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+------+-------------+----------+--------+--------------------------------------------------------+--------------+---------+-----------------------------+------+----------+-------------+
| 1 | SIMPLE | supplier | index | PRIMARY | PRIMARY | 4 | NULL | 10 | 100.00 | Using index |
| 1 | SIMPLE | partsupp | ref | PRIMARY,i_ps_partkey,i_ps_suppkey | i_ps_suppkey | 4 | dbt3old.supplier.s_suppkey | 70 | 39.69 | Using where |
| 1 | SIMPLE | part | eq_ref | PRIMARY | PRIMARY | 4 | dbt3old.partsupp.ps_partkey | 1 | 100.00 | Using index |
| 1 | SIMPLE | lineitem | ref | PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity | i_l_suppkey | 5 | dbt3old.supplier.s_suppkey | 600 | 100.00 | |
| 1 | SIMPLE | orders | eq_ref | PRIMARY,i_o_custkey | PRIMARY | 4 | dbt3old.lineitem.l_orderkey | 1 | 100.00 | Using where |
| 1 | SIMPLE | customer | eq_ref | PRIMARY | PRIMARY | 4 | dbt3old.orders.o_custkey | 1 | 100.00 | Using index |
+------+-------------+----------+--------+--------------------------------------------------------+--------------+---------+-----------------------------+------+----------+-------------+
It takes about 10 seconds on my machine on debug build.