Reproducible on 10.4 with MyIsam, not with InnoDB
CREATE TABLE t1 (d varchar(10)) ENGINE=MyISAM;
|
INSERT INTO t1 VALUES ('a'),('q');
|
|
CREATE TABLE t2 (f varchar(10), a2 datetime, b int, a1 varchar(1024), pk int NOT NULL, PRIMARY KEY (pk), UNIQUE KEY (f,a1,a2), KEY f2 (f(4),a2)) ENGINE=MyISAM WITH SYSTEM VERSIONING;
|
INSERT INTO t2 VALUES ('aaa','1985-09-06',-163,'s',1),('bbb','1995-01-05',3,'pucaz',2),('ccc','0000-00-00',NULL,'help',3),('ddd',NULL,618,'v',4),('eee','1995-12-20',410,'m',5),('ffq','1976-06-12 20:02:56',NULL,'POKNC',6),('dddd','0000-00-00',-328,'hgsu',7);
|
|
SELECT t2.b FROM t1 JOIN t2 ON t1.d = t2.f WHERE t2.pk >= 20;
|
10.4 6999da9b19c3c325
|
|
mysqld: /10.4/sql/sql_select.cc:7660: void best_access_path(JOIN*, JOIN_TAB*, table_map, uint, bool, double, POSITION*, POSITION*): Assertion `tmp >= 0' failed.
|
190606 17:54:02 [ERROR] mysqld got signal 6 ;
|
|
sql/sql_select.cc:7663(best_access_path(JOIN*, st_join_table*, unsigned long long, unsigned int, bool, double, st_position*, st_position*))[0x558f269e9794]
|
sql/sql_select.cc:9356(best_extension_by_limited_search(JOIN*, unsigned long long, unsigned int, double, double, unsigned int, unsigned int, unsigned int))[0x558f269f2938]
|
sql/sql_select.cc:9433(best_extension_by_limited_search(JOIN*, unsigned long long, unsigned int, double, double, unsigned int, unsigned int, unsigned int))[0x558f269f3256]
|
sql/sql_select.cc:8568(greedy_search(JOIN*, unsigned long long, unsigned int, unsigned int, unsigned int))[0x558f269ee9b5]
|
sql/sql_select.cc:8134(choose_plan(JOIN*, unsigned long long))[0x558f269eca8c]
|
sql/sql_select.cc:5480(make_join_statistics(JOIN*, List<TABLE_LIST>&, st_dynamic_array*))[0x558f269d9ff6]
|
sql/sql_select.cc:2192(JOIN::optimize_inner())[0x558f269bae78]
|
sql/sql_select.cc:1562(JOIN::optimize())[0x558f269b5041]
|
sql/sql_select.cc:4590(mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x558f269d20a9]
|
sql/sql_select.cc:424(handle_select(THD*, LEX*, select_result*, unsigned long))[0x558f269a9091]
|
sql/sql_parse.cc:6612(execute_sqlcom_select(THD*, TABLE_LIST*))[0x558f2692e7b5]
|
sql/sql_parse.cc:3884(mysql_execute_command(THD*))[0x558f2691b914]
|
sql/sql_parse.cc:8164(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x558f26936a76]
|
sql/sql_parse.cc:1831(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x558f2690f70e]
|
sql/sql_parse.cc:1362(do_command(THD*))[0x558f2690c64b]
|
sql/sql_connect.cc:1403(do_handle_one_connection(CONNECT*))[0x558f26c81cc9]
|
sql/sql_connect.cc:1307(handle_one_connection)[0x558f26c81693]
|
perfschema/pfs.cc:1864(pfs_spawn_thread)[0x558f280155af]
|
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7ff96566d6ba]
|
x86_64/clone.S:111(clone)[0x7ff9648fe41d]
|
|
Query (0x62b00007e290): SELECT t2.b FROM t1 JOIN t2 ON t1.d = t2.f WHERE t2.pk >= 20
|
|
On 10.3:
mysqltest: At line 19: query 'CREATE TABLE t2 ( f varchar(10) , a2 datetime, b int , a1 varchar(1024) , pk int NOT NULL , PRIMARY KEY (pk), UNIQUE KEY (f,a1,a2), KEY f2 (f(4),a2)) ENGINE=MyISAM WITH SYSTEM VERSIONING' failed: 1071: Specified key was too long; max key length is 1000 bytes
if I set shorter key, then test passes
No visible problems on a non-debug build.
- relates to
-
MDEV-17081
Make optimizer aware of Mdev-371 (long unique index)
-
-
Stalled
{"report":{"fcp":1277.0999999046326,"ttfb":443,"pageVisibility":"visible","entityId":76678,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":32,"apdex":0.5,"journeyId":"35bceb0a-4971-4177-9e04-b6612ddac066","navigationType":0,"readyForUser":1394.6999998092651,"redirectCount":0,"resourceLoadedEnd":1702.0999999046326,"resourceLoadedStart":450.5,"resourceTiming":[{"duration":204.59999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":450.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":450.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":655.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":204.59999990463257,"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":450.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":450.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":655.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":267,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":450.90000009536743,"connectEnd":450.90000009536743,"connectStart":450.90000009536743,"domainLookupEnd":450.90000009536743,"domainLookupStart":450.90000009536743,"fetchStart":450.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":450.90000009536743,"responseEnd":717.9000000953674,"responseStart":717.9000000953674,"secureConnectionStart":450.90000009536743},{"duration":337.09999990463257,"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":451.09999990463257,"connectEnd":451.09999990463257,"connectStart":451.09999990463257,"domainLookupEnd":451.09999990463257,"domainLookupStart":451.09999990463257,"fetchStart":451.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":451.09999990463257,"responseEnd":788.1999998092651,"responseStart":788.1999998092651,"secureConnectionStart":451.09999990463257},{"duration":341.5,"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":451.30000019073486,"connectEnd":451.30000019073486,"connectStart":451.30000019073486,"domainLookupEnd":451.30000019073486,"domainLookupStart":451.30000019073486,"fetchStart":451.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":451.30000019073486,"responseEnd":792.8000001907349,"responseStart":792.6999998092651,"secureConnectionStart":451.30000019073486},{"duration":342.09999990463257,"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":451.40000009536743,"connectEnd":451.40000009536743,"connectStart":451.40000009536743,"domainLookupEnd":451.40000009536743,"domainLookupStart":451.40000009536743,"fetchStart":451.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":451.40000009536743,"responseEnd":793.5,"responseStart":793.5,"secureConnectionStart":451.40000009536743},{"duration":342.2000002861023,"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":451.59999990463257,"connectEnd":451.59999990463257,"connectStart":451.59999990463257,"domainLookupEnd":451.59999990463257,"domainLookupStart":451.59999990463257,"fetchStart":451.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":451.59999990463257,"responseEnd":793.8000001907349,"responseStart":793.8000001907349,"secureConnectionStart":451.59999990463257},{"duration":430,"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":451.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":451.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":881.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":342.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":452,"connectEnd":452,"connectStart":452,"domainLookupEnd":452,"domainLookupStart":452,"fetchStart":452,"redirectEnd":0,"redirectStart":0,"requestStart":452,"responseEnd":794.4000000953674,"responseStart":794.4000000953674,"secureConnectionStart":452},{"duration":429.90000009536743,"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":452.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":452.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":882.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":342.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":452.30000019073486,"connectEnd":452.30000019073486,"connectStart":452.30000019073486,"domainLookupEnd":452.30000019073486,"domainLookupStart":452.30000019073486,"fetchStart":452.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":452.30000019073486,"responseEnd":795,"responseStart":795,"secureConnectionStart":452.30000019073486},{"duration":529.2999997138977,"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":457.80000019073486,"connectEnd":457.80000019073486,"connectStart":457.80000019073486,"domainLookupEnd":457.80000019073486,"domainLookupStart":457.80000019073486,"fetchStart":457.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":457.80000019073486,"responseEnd":987.0999999046326,"responseStart":987.0999999046326,"secureConnectionStart":457.80000019073486},{"duration":1240.1999998092651,"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":457.80000019073486,"connectEnd":457.80000019073486,"connectStart":457.80000019073486,"domainLookupEnd":457.80000019073486,"domainLookupStart":457.80000019073486,"fetchStart":457.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":457.80000019073486,"responseEnd":1698,"responseStart":1698,"secureConnectionStart":457.80000019073486},{"duration":91.60000038146973,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":906.1999998092651,"connectEnd":906.1999998092651,"connectStart":906.1999998092651,"domainLookupEnd":906.1999998092651,"domainLookupStart":906.1999998092651,"fetchStart":906.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":906.1999998092651,"responseEnd":997.8000001907349,"responseStart":997.8000001907349,"secureConnectionStart":906.1999998092651},{"duration":521,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/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&whisper-enabled=true","startTime":1177.8000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1177.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1698.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":518.9000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/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&whisper-enabled=true","startTime":1180,"connectEnd":1180,"connectStart":1180,"domainLookupEnd":1180,"domainLookupStart":1180,"fetchStart":1180,"redirectEnd":0,"redirectStart":0,"requestStart":1180,"responseEnd":1698.9000000953674,"responseStart":1698.9000000953674,"secureConnectionStart":1180},{"duration":521.5999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/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&whisper-enabled=true","startTime":1180.5,"connectEnd":1180.5,"connectStart":1180.5,"domainLookupEnd":1180.5,"domainLookupStart":1180.5,"fetchStart":1180.5,"redirectEnd":0,"redirectStart":0,"requestStart":1180.5,"responseEnd":1702.0999999046326,"responseStart":1702.0999999046326,"secureConnectionStart":1180.5},{"duration":479.2000002861023,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1248.5999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1248.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1727.8000001907349,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":280,"responseStart":443,"responseEnd":455,"domLoading":448,"domInteractive":1785,"domContentLoadedEventStart":1785,"domContentLoadedEventEnd":1850,"domComplete":2282,"loadEventStart":2282,"loadEventEnd":2283,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1704.9000000953674},{"name":"bigPipe.sidebar-id.end","time":1705.9000000953674},{"name":"bigPipe.activity-panel-pipe-id.start","time":1706},{"name":"bigPipe.activity-panel-pipe-id.end","time":1708},{"name":"activityTabFullyLoaded","time":1883.9000000953674}],"measures":[],"correlationId":"2eb53746f29363","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":100,"dbReadsTimeInMs":12,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
First lets just consider the case without SYSTEM VERSIONING, now i run the select and see in the optimizer_trace
"plan_prefix": ["t1"],
"table": "t2",
"best_access_path": {
"considered_access_paths": [
{
"access_type": "ref",
"index": "f2",
"rows": 1.1e14,
"cost": 2.1562,
"chosen": true
},
so rows shos 1.1e14. The number of records in the table t2 is 7 actually, so this is some garbage data.
We get the estimate from
which returns estimates in rec_per_key, so rec_per_key estimates have some garbage value for the key f2
(gdb) p keyinfo->rec_per_key[0]
$18 = 288411799865327618
(gdb) p keyinfo->rec_per_key[1]
$19 = 4785147619639637
The issue is that for UNIQUE long keys for which we create a hash, rec_per_key is allocated for all the keyparts of the key though on the storage engine level we will have only 1 keypart. On the sql layer we have all the keyparts but we dont make use of rec_per_key for such keys.
So the solution to fix this would be to use rec_per_key for long unique keys as only 1 keypart, that means rec_per_key[0] would have the estimate.