If a table have partitions and you try to change a column
(modify or change) with an index, which is not the partitions key,
algorithm = instant not work.
MariaDB [l1]> ALTER online TABLE t1 MODIFY COLUMN `f4` VARCHAR(500) , ALGORITHM=INSTANT, LOCK=NONE;
|
ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
|
To reproduce:
|
|
drop table if exists t1;
|
|
|
CREATE TABLE `t1` (
|
`f1` datetime ,
|
`f2` VARCHAR(2) ,
|
`f3` VARCHAR(200) ,
|
`f4` VARCHAR(100) ,
|
INDEX `i3` (`f4`) )
|
/*!50100 PARTITION BY RANGE COLUMNS(`f2`) (PARTITION `p_01` VALUES LESS THAN ('02') ENGINE = InnoDB, PARTITION `p_31` VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB) */;
|
|
|
ALTER online TABLE t1 MODIFY COLUMN `f4` VARCHAR(500) , ALGORITHM=INSTANT, LOCK=NONE;
|
If you do the testcase without index
OR !
without partition term,
it works.
{"report":{"fcp":991.2000000476837,"ttfb":275.30000001192093,"pageVisibility":"visible","entityId":130458,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"9b4ea30a-2491-4e2d-9779-36f605fbd68d","navigationType":0,"readyForUser":1076.9000000357628,"redirectCount":0,"resourceLoadedEnd":1225.1000000238419,"resourceLoadedStart":310,"resourceTiming":[{"duration":145.30000001192093,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":310,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":310,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":455.30000001192093,"responseStart":0,"secureConnectionStart":0},{"duration":216.30000001192093,"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":310.30000001192093,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":310.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":526.6000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":226.19999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":310.4000000357628,"connectEnd":310.4000000357628,"connectStart":310.4000000357628,"domainLookupEnd":310.4000000357628,"domainLookupStart":310.4000000357628,"fetchStart":310.4000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":310.4000000357628,"responseEnd":536.6000000238419,"responseStart":536.6000000238419,"secureConnectionStart":310.4000000357628},{"duration":287,"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":310.7000000476837,"connectEnd":310.7000000476837,"connectStart":310.7000000476837,"domainLookupEnd":310.7000000476837,"domainLookupStart":310.7000000476837,"fetchStart":310.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":310.7000000476837,"responseEnd":597.7000000476837,"responseStart":597.7000000476837,"secureConnectionStart":310.7000000476837},{"duration":290.5999999642372,"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":310.9000000357628,"connectEnd":310.9000000357628,"connectStart":310.9000000357628,"domainLookupEnd":310.9000000357628,"domainLookupStart":310.9000000357628,"fetchStart":310.9000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":310.9000000357628,"responseEnd":601.5,"responseStart":601.5,"secureConnectionStart":310.9000000357628},{"duration":291.19999998807907,"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":311.10000002384186,"connectEnd":311.10000002384186,"connectStart":311.10000002384186,"domainLookupEnd":311.10000002384186,"domainLookupStart":311.10000002384186,"fetchStart":311.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":311.10000002384186,"responseEnd":602.3000000119209,"responseStart":602.3000000119209,"secureConnectionStart":311.10000002384186},{"duration":292.39999997615814,"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":311.2000000476837,"connectEnd":311.2000000476837,"connectStart":311.2000000476837,"domainLookupEnd":311.2000000476837,"domainLookupStart":311.2000000476837,"fetchStart":311.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":311.2000000476837,"responseEnd":603.6000000238419,"responseStart":603.6000000238419,"secureConnectionStart":311.2000000476837},{"duration":368.30000001192093,"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":311.4000000357628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":311.4000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":679.7000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":293.80000001192093,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":311.5,"connectEnd":311.5,"connectStart":311.5,"domainLookupEnd":311.5,"domainLookupStart":311.5,"fetchStart":311.5,"redirectEnd":0,"redirectStart":0,"requestStart":311.5,"responseEnd":605.3000000119209,"responseStart":605.3000000119209,"secureConnectionStart":311.5},{"duration":368.10000002384186,"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":311.80000001192093,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":311.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":679.9000000357628,"responseStart":0,"secureConnectionStart":0},{"duration":296.5999999642372,"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":311.9000000357628,"connectEnd":311.9000000357628,"connectStart":311.9000000357628,"domainLookupEnd":311.9000000357628,"domainLookupStart":311.9000000357628,"fetchStart":311.9000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":311.9000000357628,"responseEnd":608.5,"responseStart":608.5,"secureConnectionStart":311.9000000357628},{"duration":603,"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":312.9000000357628,"connectEnd":312.9000000357628,"connectStart":312.9000000357628,"domainLookupEnd":312.9000000357628,"domainLookupStart":312.9000000357628,"fetchStart":312.9000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":312.9000000357628,"responseEnd":915.9000000357628,"responseStart":915.9000000357628,"secureConnectionStart":312.9000000357628},{"duration":912.1999999880791,"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":312.9000000357628,"connectEnd":312.9000000357628,"connectStart":312.9000000357628,"domainLookupEnd":312.9000000357628,"domainLookupStart":312.9000000357628,"fetchStart":312.9000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":312.9000000357628,"responseEnd":1225.1000000238419,"responseStart":1225.1000000238419,"secureConnectionStart":312.9000000357628},{"duration":249.20000004768372,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":707.5,"connectEnd":707.5,"connectStart":707.5,"domainLookupEnd":707.5,"domainLookupStart":707.5,"fetchStart":707.5,"redirectEnd":0,"redirectStart":0,"requestStart":707.5,"responseEnd":956.7000000476837,"responseStart":956.7000000476837,"secureConnectionStart":707.5}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":22,"responseStart":275,"responseEnd":296,"domLoading":306,"domInteractive":1261,"domContentLoadedEventStart":1261,"domContentLoadedEventEnd":1312,"domComplete":1608,"loadEventStart":1608,"loadEventEnd":1608,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1229.9000000357628},{"name":"bigPipe.sidebar-id.end","time":1230.7000000476837},{"name":"bigPipe.activity-panel-pipe-id.start","time":1231},{"name":"bigPipe.activity-panel-pipe-id.end","time":1234.800000011921},{"name":"activityTabFullyLoaded","time":1330}],"measures":[],"correlationId":"4c001b3d25c9ae","effectiveType":"4g","downlink":9.4,"rtt":0,"serverDuration":185,"dbReadsTimeInMs":17,"dbConnsTimeInMs":26,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
CREATE TABLE `t1` (
`f1` datetime ,
`f2` VARCHAR(2) ,
`f3` VARCHAR(200) ,
`f4` VARCHAR(100) ,
INDEX `i3` (`f4`) )engine=innodb;
ALTER online TABLE t1 MODIFY COLUMN `f4` VARCHAR(500) , ALGORITHM=INSTANT, LOCK=NONE;
Above test case passes with INSTANT algorithm. Why it passes?
compare_keys_but_name does call compare_key_parts(). Since it is a InnoDB engine,
it does call ha_innobase::compare_key_parts() and returns Compare_keys::EqualButKeyPartLength.
This makes the index not to rebuild.
But in case of partition, alter call handler::compare_key_parts() and returns Compare_keys::NotEqual
This lead to index rebuild. Yes, InnoDB instant doesn't support when InnoDB has to modify the column
and rebuild the index. imo, partition has to implement compare_key_parts() in their code and it should
call underlined engine compare_key_parts().