ALTER TABLE ... DISCARD TABLESPACE takes a lot of time with large buffer pool (>128G).
Steps to reproduce:
1. drop / create an InnoDB table
2. discard the table space
3. increase the buffer pool size.
4. Re-try once you have a 128G+ buffer pool, and re-run #1 & #2.
The discard time should be increasing.
{"report":{"fcp":925.2000002861023,"ttfb":294,"pageVisibility":"visible","entityId":62276,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"f7a96719-ec29-449c-a489-b024a4bc9a8d","navigationType":0,"readyForUser":1051.4000000953674,"redirectCount":0,"resourceLoadedEnd":656.1000003814697,"resourceLoadedStart":299.40000009536743,"resourceTiming":[{"duration":24.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":299.40000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":299.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":323.5,"responseStart":0,"secureConnectionStart":0},{"duration":24.09999990463257,"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":299.6000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":299.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":323.7000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":189.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":299.80000019073486,"connectEnd":299.80000019073486,"connectStart":299.80000019073486,"domainLookupEnd":299.80000019073486,"domainLookupStart":299.80000019073486,"fetchStart":299.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":326.30000019073486,"responseEnd":489.1000003814697,"responseStart":342.90000009536743,"secureConnectionStart":299.80000019073486},{"duration":356.1000003814697,"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":300,"connectEnd":300,"connectStart":300,"domainLookupEnd":300,"domainLookupStart":300,"fetchStart":300,"redirectEnd":0,"redirectStart":0,"requestStart":331.30000019073486,"responseEnd":656.1000003814697,"responseStart":347.5,"secureConnectionStart":300},{"duration":53.90000009536743,"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":300.2000002861023,"connectEnd":300.2000002861023,"connectStart":300.2000002861023,"domainLookupEnd":300.2000002861023,"domainLookupStart":300.2000002861023,"fetchStart":300.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":334,"responseEnd":354.1000003814697,"responseStart":350.1000003814697,"secureConnectionStart":300.2000002861023},{"duration":54,"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":300.40000009536743,"connectEnd":300.40000009536743,"connectStart":300.40000009536743,"domainLookupEnd":300.40000009536743,"domainLookupStart":300.40000009536743,"fetchStart":300.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":334.5,"responseEnd":354.40000009536743,"responseStart":351.1000003814697,"secureConnectionStart":300.40000009536743},{"duration":62.60000038146973,"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":300.5,"connectEnd":300.5,"connectStart":300.5,"domainLookupEnd":300.5,"domainLookupStart":300.5,"fetchStart":300.5,"redirectEnd":0,"redirectStart":0,"requestStart":340.6000003814697,"responseEnd":363.1000003814697,"responseStart":358.1000003814697,"secureConnectionStart":300.5},{"duration":33.09999990463257,"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":300.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":300.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":333.90000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":62.700000286102295,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":301,"connectEnd":301,"connectStart":301,"domainLookupEnd":301,"domainLookupStart":301,"fetchStart":301,"redirectEnd":0,"redirectStart":0,"requestStart":341.7000002861023,"responseEnd":363.7000002861023,"responseStart":359.40000009536743,"secureConnectionStart":301},{"duration":36,"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":301.2000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":301.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":337.2000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":63,"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":301.30000019073486,"connectEnd":301.30000019073486,"connectStart":301.30000019073486,"domainLookupEnd":301.30000019073486,"domainLookupStart":301.30000019073486,"fetchStart":301.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":344.30000019073486,"responseEnd":364.30000019073486,"responseStart":360.80000019073486,"secureConnectionStart":301.30000019073486},{"duration":275.5,"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":308.5,"connectEnd":308.5,"connectStart":308.5,"domainLookupEnd":308.5,"domainLookupStart":308.5,"fetchStart":308.5,"redirectEnd":0,"redirectStart":0,"requestStart":387.40000009536743,"responseEnd":584,"responseStart":575.9000000953674,"secureConnectionStart":308.5},{"duration":276.3999996185303,"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":308.6000003814697,"connectEnd":308.6000003814697,"connectStart":308.6000003814697,"domainLookupEnd":308.6000003814697,"domainLookupStart":308.6000003814697,"fetchStart":308.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":401.1000003814697,"responseEnd":585,"responseStart":579.5,"secureConnectionStart":308.6000003814697},{"duration":80.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":632.7000002861023,"connectEnd":632.7000002861023,"connectStart":632.7000002861023,"domainLookupEnd":632.7000002861023,"domainLookupStart":632.7000002861023,"fetchStart":632.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":681.2000002861023,"responseEnd":713.2000002861023,"responseStart":712.4000000953674,"secureConnectionStart":632.7000002861023},{"duration":264.2000002861023,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":878.9000000953674,"connectEnd":878.9000000953674,"connectStart":878.9000000953674,"domainLookupEnd":878.9000000953674,"domainLookupStart":878.9000000953674,"fetchStart":878.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":1110.1000003814697,"responseEnd":1143.1000003814697,"responseStart":1141.6000003814697,"secureConnectionStart":878.9000000953674},{"duration":205.2999997138977,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":918.2000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":918.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1123.5,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":96,"responseStart":294,"responseEnd":307,"domLoading":297,"domInteractive":1126,"domContentLoadedEventStart":1126,"domContentLoadedEventEnd":1186,"domComplete":1788,"loadEventStart":1788,"loadEventEnd":1789,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1095.6000003814697},{"name":"bigPipe.sidebar-id.end","time":1096.3000001907349},{"name":"bigPipe.activity-panel-pipe-id.start","time":1096.5},{"name":"bigPipe.activity-panel-pipe-id.end","time":1098.9000000953674},{"name":"activityTabFullyLoaded","time":1207.6000003814697}],"measures":[],"correlationId":"c24e9f2c7bd7e2","effectiveType":"4g","downlink":9.6,"rtt":0,"serverDuration":118,"dbReadsTimeInMs":16,"dbConnsTimeInMs":25,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
If DISCARD TABLESPACE does not evict the pages from the buffer pool, then IMPORT TABLESPACE must do it. It would not be a useful fix to simply move the call to the IMPORT TABLESPACE step.
I tried simply removing the eviction in DISCARD TABLESPACE. If the DISCARD is soon followed by IMPORT, the IMPORT would adjust the imported file to the pre-existing tablespace ID. If the old pages were not evicted from the buffer pool at DISCARD, then after IMPORT we could incorrectly read old pages from the buffer pool, instead of reading the pages that exist in the imported file.
Import is initially bypassing the buffer pool when reading pages for the adjustment phase. A possible fix is that in the adjustment phase, if a page exists in the buffer pool, we would replace it with the page from the imported file. This would allow quick DISCARD TABLESPACE even for large tables, and a slightly slower IMPORT TABLESPACE (the slowness being proportional to the file size).