I create and populate two tables as follows:
SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35');
|
DROP TABLE IF EXISTS t1, t2;
|
CREATE TABLE t1 (col_time_key TIME, KEY(col_time_key));
|
CREATE TABLE t2 (col_datetime_key DATETIME);
|
INSERT INTO t1 VALUES ('-760:00:00'),('760:00:00');
|
INSERT INTO t1 VALUES ('-770:00:00'),('770:00:00');
|
INSERT INTO t2 SELECT * FROM t1;
|
Now I run this query with IGNORE INDEX, it returns four rows as expected:
SELECT * FROM t2 STRAIGHT_JOIN t1 IGNORE INDEX(col_time_key) WHERE col_time_key = col_datetime_key;
|
+---------------------+--------------+
|
| col_datetime_key | col_time_key |
|
+---------------------+--------------+
|
| 2011-12-30 08:00:00 | -760:00:00 |
|
| 2012-03-02 16:00:00 | 760:00:00 |
|
| 2011-12-29 22:00:00 | -770:00:00 |
|
| 2012-03-03 02:00:00 | 770:00:00 |
|
+---------------------+--------------+
|
Now I run the same query but with FORCE INDEX, it erroneously returns three rows:
SELECT * FROM t2 STRAIGHT_JOIN t1 FORCE INDEX (col_time_key) WHERE col_time_key = col_datetime_key;
|
+---------------------+--------------+
|
| col_datetime_key | col_time_key |
|
+---------------------+--------------+
|
| 2011-12-30 08:00:00 | -760:00:00 |
|
| 2012-03-02 16:00:00 | 760:00:00 |
|
| 2012-03-03 02:00:00 | 770:00:00 |
|
+---------------------+--------------+
|
Transition |
Time In Source Status |
Execution Times |
Open |
|
In Progress |
|
1h 59m
|
1
|
In Progress |
|
Closed |
|
14s
|
1
|
{"report":{"fcp":839.2000002861023,"ttfb":142.09999990463257,"pageVisibility":"visible","entityId":65812,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"352c8803-a169-49b2-8e0a-66b939b82c5e","navigationType":0,"readyForUser":921.9000000953674,"redirectCount":0,"resourceLoadedEnd":944.9000000953674,"resourceLoadedStart":147.09999990463257,"resourceTiming":[{"duration":139.7000002861023,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bsh/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":147.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":147.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":286.80000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":139.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":147.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":147.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":286.90000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":148.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/c54b129276d75dc2a3460e1d78f37913-CDN/lu2bsh/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":147.5,"connectEnd":147.5,"connectStart":147.5,"domainLookupEnd":147.5,"domainLookupStart":147.5,"fetchStart":147.5,"redirectEnd":0,"redirectStart":0,"requestStart":147.5,"responseEnd":295.90000009536743,"responseStart":295.90000009536743,"secureConnectionStart":147.5},{"duration":326.90000009536743,"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":147.59999990463257,"connectEnd":147.59999990463257,"connectStart":147.59999990463257,"domainLookupEnd":147.59999990463257,"domainLookupStart":147.59999990463257,"fetchStart":147.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":147.59999990463257,"responseEnd":474.5,"responseStart":474.5,"secureConnectionStart":147.59999990463257},{"duration":330.5,"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":147.7000002861023,"connectEnd":147.7000002861023,"connectStart":147.7000002861023,"domainLookupEnd":147.7000002861023,"domainLookupStart":147.7000002861023,"fetchStart":147.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":147.7000002861023,"responseEnd":478.2000002861023,"responseStart":478.2000002861023,"secureConnectionStart":147.7000002861023},{"duration":330.7999997138977,"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":147.7000002861023,"connectEnd":147.7000002861023,"connectStart":147.7000002861023,"domainLookupEnd":147.7000002861023,"domainLookupStart":147.7000002861023,"fetchStart":147.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":147.7000002861023,"responseEnd":478.5,"responseStart":478.5,"secureConnectionStart":147.7000002861023},{"duration":331,"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":147.90000009536743,"connectEnd":147.90000009536743,"connectStart":147.90000009536743,"domainLookupEnd":147.90000009536743,"domainLookupStart":147.90000009536743,"fetchStart":147.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":147.90000009536743,"responseEnd":478.90000009536743,"responseStart":478.90000009536743,"secureConnectionStart":147.90000009536743},{"duration":331.2000002861023,"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":148,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":148,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":479.2000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":331.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":148,"connectEnd":148,"connectStart":148,"domainLookupEnd":148,"domainLookupStart":148,"fetchStart":148,"redirectEnd":0,"redirectStart":0,"requestStart":148,"responseEnd":479.40000009536743,"responseStart":479.40000009536743,"secureConnectionStart":148},{"duration":331.5,"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":148.2000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":148.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":479.7000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":331.59999990463257,"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":148.30000019073486,"connectEnd":148.30000019073486,"connectStart":148.30000019073486,"domainLookupEnd":148.30000019073486,"domainLookupStart":148.30000019073486,"fetchStart":148.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":148.30000019073486,"responseEnd":479.90000009536743,"responseStart":479.80000019073486,"secureConnectionStart":148.30000019073486},{"duration":419.7000002861023,"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":153.5,"connectEnd":153.5,"connectStart":153.5,"domainLookupEnd":153.5,"domainLookupStart":153.5,"fetchStart":153.5,"redirectEnd":0,"redirectStart":0,"requestStart":153.5,"responseEnd":573.2000002861023,"responseStart":573.2000002861023,"secureConnectionStart":153.5},{"duration":750.5999999046326,"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":153.7000002861023,"connectEnd":153.7000002861023,"connectStart":153.7000002861023,"domainLookupEnd":153.7000002861023,"domainLookupStart":153.7000002861023,"fetchStart":153.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":153.7000002861023,"responseEnd":904.3000001907349,"responseStart":904.3000001907349,"secureConnectionStart":153.7000002861023},{"duration":117.30000019073486,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":444.59999990463257,"connectEnd":444.59999990463257,"connectStart":444.59999990463257,"domainLookupEnd":444.59999990463257,"domainLookupStart":444.59999990463257,"fetchStart":444.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":444.59999990463257,"responseEnd":561.9000000953674,"responseStart":561.9000000953674,"secureConnectionStart":444.59999990463257},{"duration":188.19999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bsh/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":756.7000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":756.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":944.9000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":256.2000002861023,"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":757.5,"connectEnd":757.5,"connectStart":757.5,"domainLookupEnd":757.5,"domainLookupStart":757.5,"fetchStart":757.5,"redirectEnd":0,"redirectStart":0,"requestStart":757.5,"responseEnd":1013.7000002861023,"responseStart":1013.7000002861023,"secureConnectionStart":757.5},{"duration":260.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/4a55b33fb6014f6055f885e193bf4347-CDN/lu2bsh/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":757.9000000953674,"connectEnd":757.9000000953674,"connectStart":757.9000000953674,"domainLookupEnd":757.9000000953674,"domainLookupStart":757.9000000953674,"fetchStart":757.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":757.9000000953674,"responseEnd":1018.4000000953674,"responseStart":1018.4000000953674,"secureConnectionStart":757.9000000953674},{"duration":186.90000009536743,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":832.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":832.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1019.4000000953674,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":10,"responseStart":142,"responseEnd":151,"domLoading":145,"domInteractive":981,"domContentLoadedEventStart":981,"domContentLoadedEventEnd":1023,"domComplete":1162,"loadEventStart":1162,"loadEventEnd":1162,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":961.4000000953674},{"name":"bigPipe.sidebar-id.end","time":962.2000002861023},{"name":"bigPipe.activity-panel-pipe-id.start","time":962.4000000953674},{"name":"bigPipe.activity-panel-pipe-id.end","time":963.4000000953674},{"name":"activityTabFullyLoaded","time":1040.4000000953674}],"measures":[],"correlationId":"9ae06f8052382c","effectiveType":"4g","downlink":9.7,"rtt":0,"serverDuration":76,"dbReadsTimeInMs":18,"dbConnsTimeInMs":25,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}