-
Bug
-
-
Minor
-
Resolution:
Fixed
-
10.5
-
-
-
Take the DBT-3 dataset, make sure you have these indexes:
CREATE INDEX i_o_orderdate ON orders (o_orderdate);
|
CREATE INDEX i_o_custkey ON orders (o_custkey);
|
Run these two queries. The queries are the same, except for the ORDER BY list.
However this difference causes different join orders to be picked:
MariaDB [dbt3]> explain select * from orders,customer where o_custkey=c_custkey order by o_orderdate limit 10;
|
+------+-------------+----------+--------+---------------+---------------+---------+-----------------------+------+-------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+----------+--------+---------------+---------------+---------+-----------------------+------+-------------+
|
| 1 | SIMPLE | orders | index | i_o_custkey | i_o_orderdate | 4 | NULL | 10 | Using where |
|
| 1 | SIMPLE | customer | eq_ref | PRIMARY | PRIMARY | 4 | dbt3.orders.o_custkey | 1 | |
|
+------+-------------+----------+--------+---------------+---------------+---------+-----------------------+------+-------------+
|
MariaDB [dbt3]> explain select * from orders,customer where o_custkey=c_custkey order by c_acctbal limit 10;
|
+------+-------------+----------+-------+---------------+-------------+---------+-------------------------+------+-------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+----------+-------+---------------+-------------+---------+-------------------------+------+-------+
|
| 1 | SIMPLE | customer | index | PRIMARY | c_acctbal | 9 | NULL | 1 | |
|
| 1 | SIMPLE | orders | ref | i_o_custkey | i_o_custkey | 5 | dbt3.customer.c_custkey | 15 | |
|
+------+-------------+----------+-------+---------------+-------------+---------+-------------------------+------+-------+
|
However, looking at the optimizer trace, one can see that the join optimization parts are identical:
MariaDB [dbt3]> select * from information_schema.optimizer_trace\G
|
*************************** 1. row ***************************
|
- QUERY: explain select * from orders,customer where o_custkey=c_custkey order by o_orderdate limit 10
|
+ QUERY: explain select * from orders,customer where o_custkey=c_custkey order by c_acctbal limit 10
|
TRACE: {
|
"steps": [
|
{
|
@@ -18,7 +17,7 @@
|
"select_id": 1,
|
"steps": [
|
{
|
- "expanded_query": ...
|
+ "expanded_query": ...
|
}
|
]
|
}
|
@@ -177,15 +176,15 @@
|
},
|
{
|
"attaching_conditions_to_tables": {
|
- "original_condition": "customer.c_custkey = orders.o_custkey",
|
+ "original_condition": "orders.o_custkey = customer.c_custkey",
|
"attached_conditions_computation": [],
|
"attached_conditions_summary": [
|
{
|
- "table": "orders",
|
- "attached": "orders.o_custkey is not null"
|
+ "table": "customer",
|
+ "attached": null
|
},
|
The first difference is in "attaching_conditions_to_tables" ?
{"report":{"fcp":751.1000003814697,"ttfb":150.7000002861023,"pageVisibility":"visible","entityId":82871,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"714d7c5e-26a6-408d-a8f7-4e5cbb3f53f6","navigationType":0,"readyForUser":872.5,"redirectCount":0,"resourceLoadedEnd":946.1000003814697,"resourceLoadedStart":155.30000019073486,"resourceTiming":[{"duration":186.69999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bsh/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":155.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":155.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":342,"responseStart":0,"secureConnectionStart":0},{"duration":182.59999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bsh/820016/12ta74/eb142f92e4bd16bd1ef8b08c1b9d5d56/_/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","startTime":159.40000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":159.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":342,"responseStart":0,"secureConnectionStart":0},{"duration":193.39999961853027,"initiatorType":"script","name":"https://jira.mariadb.org/s/c54b129276d75dc2a3460e1d78f37913-CDN/lu2bsh/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":159.60000038146973,"connectEnd":159.60000038146973,"connectStart":159.60000038146973,"domainLookupEnd":159.60000038146973,"domainLookupStart":159.60000038146973,"fetchStart":159.60000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":159.60000038146973,"responseEnd":353,"responseStart":353,"secureConnectionStart":159.60000038146973},{"duration":273.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/f867843cd2fdb209d4d1d4f760f86346-CDN/lu2bsh/820016/12ta74/eb142f92e4bd16bd1ef8b08c1b9d5d56/_/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","startTime":159.90000009536743,"connectEnd":159.90000009536743,"connectStart":159.90000009536743,"domainLookupEnd":159.90000009536743,"domainLookupStart":159.90000009536743,"fetchStart":159.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":159.90000009536743,"responseEnd":433.5,"responseStart":433.5,"secureConnectionStart":159.90000009536743},{"duration":277.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/ffdb17665775c5b4d6f097f3974ee359-CDN/lu2bsh/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":160.10000038146973,"connectEnd":160.10000038146973,"connectStart":160.10000038146973,"domainLookupEnd":160.10000038146973,"domainLookupStart":160.10000038146973,"fetchStart":160.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":160.10000038146973,"responseEnd":437.30000019073486,"responseStart":437.30000019073486,"secureConnectionStart":160.10000038146973},{"duration":278,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bsh/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":160.10000038146973,"connectEnd":160.10000038146973,"connectStart":160.10000038146973,"domainLookupEnd":160.10000038146973,"domainLookupStart":160.10000038146973,"fetchStart":160.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":160.10000038146973,"responseEnd":438.1000003814697,"responseStart":438.1000003814697,"secureConnectionStart":160.10000038146973},{"duration":278.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bsh/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":160.10000038146973,"connectEnd":160.10000038146973,"connectStart":160.10000038146973,"domainLookupEnd":160.10000038146973,"domainLookupStart":160.10000038146973,"fetchStart":160.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":160.10000038146973,"responseEnd":438.6000003814697,"responseStart":438.6000003814697,"secureConnectionStart":160.10000038146973},{"duration":278.69999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bsh/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":160.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":160.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":439,"responseStart":0,"secureConnectionStart":0},{"duration":279.6000003814697,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bsh/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":160.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":160.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":440.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":278.6000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":160.5,"connectEnd":160.5,"connectStart":160.5,"domainLookupEnd":160.5,"domainLookupStart":160.5,"fetchStart":160.5,"redirectEnd":0,"redirectStart":0,"requestStart":160.5,"responseEnd":439.1000003814697,"responseStart":439.1000003814697,"secureConnectionStart":160.5},{"duration":279.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/81b5d7c27af3ebc078cc4a36383678ba-CDN/lu2bsh/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":160.60000038146973,"connectEnd":160.60000038146973,"connectStart":160.60000038146973,"domainLookupEnd":160.60000038146973,"domainLookupStart":160.60000038146973,"fetchStart":160.60000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":160.60000038146973,"responseEnd":440.30000019073486,"responseStart":440.30000019073486,"secureConnectionStart":160.60000038146973},{"duration":556.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bsh/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":182.30000019073486,"connectEnd":182.30000019073486,"connectStart":182.30000019073486,"domainLookupEnd":182.30000019073486,"domainLookupStart":182.30000019073486,"fetchStart":182.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":182.30000019073486,"responseEnd":738.6000003814697,"responseStart":738.6000003814697,"secureConnectionStart":182.30000019073486},{"duration":696.2999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bsh/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":188.2000002861023,"connectEnd":188.2000002861023,"connectStart":188.2000002861023,"domainLookupEnd":188.2000002861023,"domainLookupStart":188.2000002861023,"fetchStart":188.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":188.2000002861023,"responseEnd":884.5,"responseStart":884.5,"secureConnectionStart":188.2000002861023},{"duration":237.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":502.1000003814697,"connectEnd":502.1000003814697,"connectStart":502.1000003814697,"domainLookupEnd":502.1000003814697,"domainLookupStart":502.1000003814697,"fetchStart":502.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":502.1000003814697,"responseEnd":739.6000003814697,"responseStart":739.6000003814697,"secureConnectionStart":502.1000003814697},{"duration":141.90000009536743,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":744.2000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":744.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":886.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":177.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bsh/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":768.2000002861023,"connectEnd":768.2000002861023,"connectStart":768.2000002861023,"domainLookupEnd":768.2000002861023,"domainLookupStart":768.2000002861023,"fetchStart":768.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":768.2000002861023,"responseEnd":946.1000003814697,"responseStart":946,"secureConnectionStart":768.2000002861023}],"fetchStart":1,"domainLookupStart":1,"domainLookupEnd":1,"connectStart":1,"connectEnd":1,"requestStart":25,"responseStart":151,"responseEnd":189,"domLoading":154,"domInteractive":973,"domContentLoadedEventStart":973,"domContentLoadedEventEnd":1017,"domComplete":1435,"loadEventStart":1435,"loadEventEnd":1435,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":943.9000000953674},{"name":"bigPipe.sidebar-id.end","time":944.7000002861023},{"name":"bigPipe.activity-panel-pipe-id.start","time":944.9000000953674},{"name":"bigPipe.activity-panel-pipe-id.end","time":946},{"name":"activityTabFullyLoaded","time":1035}],"measures":[],"correlationId":"cbc144c261bccc","effectiveType":"4g","downlink":9.5,"rtt":0,"serverDuration":72,"dbReadsTimeInMs":14,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}