Reproduce
-- source include/have_partition.inc
|
|
set timestamp= unix_timestamp('2000-01-01 00:00:00');
|
create or replace table t1 (x int) with system versioning
|
partition by system_time interval 1 hour;
|
|
insert into t1 values (0);
|
update t1 set x= x + 1;
|
|
set timestamp= unix_timestamp('2000-01-01 01:00:01');
|
update t1 set x= x + 1;
|
|
select *, row_start, row_end from t1 for system_time as of '2000-01-01 01:00:00';
|
--replace_column 10 #
|
explain partitions select * from t1 for system_time as of '2000-01-01 01:00:00';
|
|
drop tables t1;
|
Result
set timestamp= unix_timestamp('2000-01-01 00:00:00');
|
create or replace table t1 (x int) with system versioning
|
partition by system_time interval 1 hour;
|
insert into t1 values (0);
|
update t1 set x= x + 1;
|
set timestamp= unix_timestamp('2000-01-01 01:00:01');
|
update t1 set x= x + 1;
|
Warnings:
|
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p0`) is out of INTERVAL, need more HISTORY partitions
|
select *, row_start, row_end from t1 for system_time as of '2000-01-01 01:00:00';
|
x row_start row_end
|
explain partitions select * from t1 for system_time as of '2000-01-01 01:00:00';
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
|
drop tables t1;
|
Expected
SELECT displays "1" record.
Compare with result from 3 partitions:
set timestamp= unix_timestamp('2000-01-01 00:00:00');
|
create or replace table t1 (x int) with system versioning
|
partition by system_time interval 1 hour partitions 3;
|
insert into t1 values (0);
|
update t1 set x= x + 1;
|
set timestamp= unix_timestamp('2000-01-01 01:00:01');
|
update t1 set x= x + 1;
|
select *, row_start, row_end from t1 for system_time as of '2000-01-01 01:00:00';
|
x row_start row_end
|
1 2000-01-01 00:00:00.000000 2000-01-01 01:00:01.000000
|
explain partitions select * from t1 for system_time as of '2000-01-01 01:00:00';
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
1 SIMPLE t1 p1,pn ALL NULL NULL NULL NULL # Using where
|
drop tables t1;
|
Proposed fix
1. When overflow warning occurs touch file t1.no_pruning.
2. When share open sees that file it sets no_pruning property to TABLE_SHARE.
3. Pruning sees that property, selects all partitions and issues warning that pruning is off.
4. After partitioning rebuild this file is removed.
{"report":{"fcp":1051.8000001907349,"ttfb":303,"pageVisibility":"visible","entityId":85484,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"c7ad7aec-4902-4ba1-a83b-64e9dd3ad1a0","navigationType":0,"readyForUser":1196.8000001907349,"redirectCount":0,"resourceLoadedEnd":758.4000000953674,"resourceLoadedStart":317.30000019073486,"resourceTiming":[{"duration":128.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":317.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":317.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":445.40000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":128.19999980926514,"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":317.7000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":317.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":445.90000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":299.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":317.90000009536743,"connectEnd":317.90000009536743,"connectStart":317.90000009536743,"domainLookupEnd":317.90000009536743,"domainLookupStart":317.90000009536743,"fetchStart":317.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":457.59999990463257,"responseEnd":617.3000001907349,"responseStart":473.09999990463257,"secureConnectionStart":317.90000009536743},{"duration":414,"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":318.5,"connectEnd":318.5,"connectStart":318.5,"domainLookupEnd":318.5,"domainLookupStart":318.5,"fetchStart":318.5,"redirectEnd":0,"redirectStart":0,"requestStart":457.80000019073486,"responseEnd":732.5,"responseStart":477.59999990463257,"secureConnectionStart":318.5},{"duration":163.09999990463257,"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":318.7000002861023,"connectEnd":318.7000002861023,"connectStart":318.7000002861023,"domainLookupEnd":318.7000002861023,"domainLookupStart":318.7000002861023,"fetchStart":318.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":458,"responseEnd":481.80000019073486,"responseStart":476.90000009536743,"secureConnectionStart":318.7000002861023},{"duration":163.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":318.90000009536743,"connectEnd":318.90000009536743,"connectStart":318.90000009536743,"domainLookupEnd":318.90000009536743,"domainLookupStart":318.90000009536743,"fetchStart":318.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":458.2000002861023,"responseEnd":482,"responseStart":478.40000009536743,"secureConnectionStart":318.90000009536743},{"duration":163.80000019073486,"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":319,"connectEnd":319,"connectStart":319,"domainLookupEnd":319,"domainLookupStart":319,"fetchStart":319,"redirectEnd":0,"redirectStart":0,"requestStart":458.7000002861023,"responseEnd":482.80000019073486,"responseStart":479.5,"secureConnectionStart":319},{"duration":134.5,"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":319.2000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":319.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":453.7000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":166.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":319.30000019073486,"connectEnd":319.30000019073486,"connectStart":319.30000019073486,"domainLookupEnd":319.30000019073486,"domainLookupStart":319.30000019073486,"fetchStart":319.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":462.80000019073486,"responseEnd":485.5,"responseStart":483.09999990463257,"secureConnectionStart":319.30000019073486},{"duration":135,"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":319.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":319.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":454.5,"responseStart":0,"secureConnectionStart":0},{"duration":167.80000019073486,"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":319.59999990463257,"connectEnd":319.59999990463257,"connectStart":319.59999990463257,"domainLookupEnd":319.59999990463257,"domainLookupStart":319.59999990463257,"fetchStart":319.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":463,"responseEnd":487.40000009536743,"responseStart":483.80000019073486,"secureConnectionStart":319.59999990463257},{"duration":424.19999980926514,"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":333.30000019073486,"connectEnd":333.30000019073486,"connectStart":333.30000019073486,"domainLookupEnd":333.30000019073486,"domainLookupStart":333.30000019073486,"fetchStart":333.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":546.7000002861023,"responseEnd":757.5,"responseStart":752.4000000953674,"secureConnectionStart":333.30000019073486},{"duration":422.09999990463257,"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":336.30000019073486,"connectEnd":336.30000019073486,"connectStart":336.30000019073486,"domainLookupEnd":336.30000019073486,"domainLookupStart":336.30000019073486,"fetchStart":336.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":672,"responseEnd":758.4000000953674,"responseStart":755,"secureConnectionStart":336.30000019073486},{"duration":119.19999980926514,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":771.8000001907349,"connectEnd":771.8000001907349,"connectStart":771.8000001907349,"domainLookupEnd":771.8000001907349,"domainLookupStart":771.8000001907349,"fetchStart":771.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":858.3000001907349,"responseEnd":891,"responseStart":890.2000002861023,"secureConnectionStart":771.8000001907349}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":117,"responseStart":303,"responseEnd":338,"domLoading":306,"domInteractive":1292,"domContentLoadedEventStart":1293,"domContentLoadedEventEnd":1359,"domComplete":2014,"loadEventStart":2014,"loadEventEnd":2014,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1243.5999999046326},{"name":"bigPipe.sidebar-id.end","time":1244.4000000953674},{"name":"bigPipe.activity-panel-pipe-id.start","time":1244.5},{"name":"bigPipe.activity-panel-pipe-id.end","time":1245.9000000953674},{"name":"activityTabFullyLoaded","time":1377.5}],"measures":[],"correlationId":"4b78d331e55418","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":102,"dbReadsTimeInMs":16,"dbConnsTimeInMs":25,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
What about this approach: for the purpose of pruning always assume that the last history partition has no end time. That is, if the requested timestamp is after the last history partition — don't prune it anyway. All other partitions can be pruned normally.