This script
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a GEOMETRY NOT NULL, SPATIAL KEY(a)) ENGINE=MyISAM;
|
INSERT INTO t1 VALUES (Point(1,2)),(Point(1,3));
|
EXPLAIN SELECT * FROM t1 WHERE MBRINTERSECTS(a,Point(1,2));
|
returns
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+
|
| 1 | SIMPLE | t1 | range | a | a | 34 | NULL | 1 | Using where |
|
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+
|
which means range optimizer is used. So far so good.
Now if I change the order of the arguments:
EXPLAIN SELECT * FROM t1 WHERE MBRINTERSECTS(Point(1,2),a);
|
it does not use the index any more:
+------+-------------+-------+------+---------------+------+---------+------+------+-------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+-------+------+---------------+------+---------+------+------+-------------+
|
| 1 | SIMPLE | t1 | ALL | a | NULL | NULL | NULL | 2 | Using where |
|
+------+-------------+-------+------+---------------+------+---------+------+------+-------------+
|
The same problem is repeatable with the precise function INTERSECTS().
Note, MBRINTERSECTS() and INTERSECTS() are symmetric operation, so the order of the arguments should not matter.
Transition |
Time In Source Status |
Execution Times |
Open |
|
Closed |
|
30d 1h 31m
|
1
|
{"report":{"fcp":880.5,"ttfb":292.5,"pageVisibility":"visible","entityId":51529,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"be87cd77-dde6-4ab4-b87e-83b976825008","navigationType":0,"readyForUser":935.1000001430511,"redirectCount":0,"resourceLoadedEnd":800.8000001907349,"resourceLoadedStart":297.90000009536743,"resourceTiming":[{"duration":73.70000004768372,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":297.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":297.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":371.60000014305115,"responseStart":0,"secureConnectionStart":0},{"duration":73.60000014305115,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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":298.2000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":298.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":371.80000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":125.89999985694885,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":298.30000019073486,"connectEnd":298.30000019073486,"connectStart":298.30000019073486,"domainLookupEnd":298.30000019073486,"domainLookupStart":298.30000019073486,"fetchStart":298.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":298.30000019073486,"responseEnd":424.2000000476837,"responseStart":424.2000000476837,"secureConnectionStart":298.30000019073486},{"duration":185.79999995231628,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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":298.40000009536743,"connectEnd":298.40000009536743,"connectStart":298.40000009536743,"domainLookupEnd":298.40000009536743,"domainLookupStart":298.40000009536743,"fetchStart":298.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":298.40000009536743,"responseEnd":484.2000000476837,"responseStart":484.2000000476837,"secureConnectionStart":298.40000009536743},{"duration":189.20000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":298.5,"connectEnd":298.5,"connectStart":298.5,"domainLookupEnd":298.5,"domainLookupStart":298.5,"fetchStart":298.5,"redirectEnd":0,"redirectStart":0,"requestStart":298.5,"responseEnd":487.7000000476837,"responseStart":487.7000000476837,"secureConnectionStart":298.5},{"duration":190.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":298.60000014305115,"connectEnd":298.60000014305115,"connectStart":298.60000014305115,"domainLookupEnd":298.60000014305115,"domainLookupStart":298.60000014305115,"fetchStart":298.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":298.60000014305115,"responseEnd":489.10000014305115,"responseStart":489.10000014305115,"secureConnectionStart":298.60000014305115},{"duration":191.29999995231628,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":298.80000019073486,"connectEnd":298.80000019073486,"connectStart":298.80000019073486,"domainLookupEnd":298.80000019073486,"domainLookupStart":298.80000019073486,"fetchStart":298.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":298.80000019073486,"responseEnd":490.10000014305115,"responseStart":490.10000014305115,"secureConnectionStart":298.80000019073486},{"duration":192.20000004768372,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":298.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":298.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":491.10000014305115,"responseStart":0,"secureConnectionStart":0},{"duration":193.10000014305115,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/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":299,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":299,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":492.10000014305115,"responseStart":0,"secureConnectionStart":0},{"duration":192.20000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":299,"connectEnd":299,"connectStart":299,"domainLookupEnd":299,"domainLookupStart":299,"fetchStart":299,"redirectEnd":0,"redirectStart":0,"requestStart":299,"responseEnd":491.2000000476837,"responseStart":491.2000000476837,"secureConnectionStart":299},{"duration":193,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/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":299.2000000476837,"connectEnd":299.2000000476837,"connectStart":299.2000000476837,"domainLookupEnd":299.2000000476837,"domainLookupStart":299.2000000476837,"fetchStart":299.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":299.2000000476837,"responseEnd":492.2000000476837,"responseStart":492.2000000476837,"secureConnectionStart":299.2000000476837},{"duration":341.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":304.40000009536743,"connectEnd":304.40000009536743,"connectStart":304.40000009536743,"domainLookupEnd":304.40000009536743,"domainLookupStart":304.40000009536743,"fetchStart":304.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":304.40000009536743,"responseEnd":646.3000001907349,"responseStart":646.3000001907349,"secureConnectionStart":304.40000009536743},{"duration":496.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":304.40000009536743,"connectEnd":304.40000009536743,"connectStart":304.40000009536743,"domainLookupEnd":304.40000009536743,"domainLookupStart":304.40000009536743,"fetchStart":304.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":304.40000009536743,"responseEnd":800.8000001907349,"responseStart":800.8000001907349,"secureConnectionStart":304.40000009536743},{"duration":163.20000004768372,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":636.2000000476837,"connectEnd":636.2000000476837,"connectStart":636.2000000476837,"domainLookupEnd":636.2000000476837,"domainLookupStart":636.2000000476837,"fetchStart":636.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":636.2000000476837,"responseEnd":799.4000000953674,"responseStart":799.4000000953674,"secureConnectionStart":636.2000000476837}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":170,"responseStart":293,"responseEnd":302,"domLoading":296,"domInteractive":982,"domContentLoadedEventStart":982,"domContentLoadedEventEnd":1014,"domComplete":1254,"loadEventStart":1254,"loadEventEnd":1254,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":966.1000001430511},{"name":"bigPipe.sidebar-id.end","time":967},{"name":"bigPipe.activity-panel-pipe-id.start","time":967.1000001430511},{"name":"bigPipe.activity-panel-pipe-id.end","time":967.9000000953674},{"name":"activityTabFullyLoaded","time":1023.9000000953674}],"measures":[],"correlationId":"f30ad7ec20e8d","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":72,"dbReadsTimeInMs":14,"dbConnsTimeInMs":21,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}