If a derived table is specified by only table value constructors then the expected number of rows displayed by EXPLAIN is always 2.
MariaDB [test]> explain select * from (values (7), (5), (8), (1), (3), (8), (1)) t;
|
+------+-------------+------------+------+---------------+------+---------+------+------+----------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+------------+------+---------------+------+---------+------+------+----------------+
|
| 1 | PRIMARY | <derived2> | ALL | NULL | NULL | NULL | NULL | 2 | |
|
| 2 | DERIVED | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used |
|
+------+-------------+------------+------+---------------+------+---------+------+------+----------------+
|
MariaDB [test]> explain select * from (values (1,11), (7,77), (3,31), (4,42)) t;
|
+------+-------------+------------+------+---------------+------+---------+------+------+----------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+------------+------+---------------+------+---------+------+------+----------------+
|
| 1 | PRIMARY | <derived2> | ALL | NULL | NULL | NULL | NULL | 2 | |
|
| 2 | DERIVED | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used |
|
+------+-------------+------------+------+---------------+------+---------+------+------+----------------+
|
2MariaDB [test]> explain select * from (values (7), (5), (8), (1) union values (3), (8), (1)) t;
|
+------+--------------+------------+------+---------------+------+---------+------+------+----------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+--------------+------------+------+---------------+------+---------+------+------+----------------+
|
| 1 | PRIMARY | <derived2> | ALL | NULL | NULL | NULL | NULL | 2 | |
|
| 2 | DERIVED | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used |
|
| 3 | UNION | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used |
|
| NULL | UNION RESULT | <union2,3> | ALL | NULL | NULL | NULL | NULL | NULL | |
|
+------+--------------+------------+------+---------------+------+---------+------+------+----------------+
|
If the specification of a derived table uses not only table value constructors the EXPLAIN
still shows a wrong number of expected rows in the derived table
MariaDB [test]> create table t1 (a int);
|
MariaDB [test]> insert into t1 values (9), (3), (2);
|
Records: 3 Duplicates: 0 Warnings: 0
|
|
MariaDB [test]> explain select * from (values (7), (5), (8), (1) union select * from t1) t;
|
+------+--------------+------------+------+---------------+------+---------+------+------+----------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+--------------+------------+------+---------------+------+---------+------+------+----------------+
|
| 1 | PRIMARY | <derived2> | ALL | NULL | NULL | NULL | NULL | 3 | |
|
| 2 | DERIVED | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used |
|
| 3 | UNION | t1 | ALL | NULL | NULL | NULL | NULL | 3 | |
|
| NULL | UNION RESULT | <union2,3> | ALL | NULL | NULL | NULL | NULL | NULL | |
|
+------+--------------+------------+------+---------------+------+---------+------+------+----------------+
|
{"report":{"fcp":1026.3000001907349,"ttfb":278.80000019073486,"pageVisibility":"visible","entityId":69269,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":32,"apdex":0.5,"journeyId":"85f82930-6072-425f-a42e-5d8ddda2036f","navigationType":0,"readyForUser":1119.5,"redirectCount":0,"resourceLoadedEnd":930,"resourceLoadedStart":285.1000003814697,"resourceTiming":[{"duration":62.89999961853027,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":285.1000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":285.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":348,"responseStart":0,"secureConnectionStart":0},{"duration":62.89999961853027,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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":285.4000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":285.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":348.30000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":248.60000038146973,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":285.6000003814697,"connectEnd":285.6000003814697,"connectStart":285.6000003814697,"domainLookupEnd":285.6000003814697,"domainLookupStart":285.6000003814697,"fetchStart":285.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":357.6000003814697,"responseEnd":534.2000007629395,"responseStart":369.5,"secureConnectionStart":285.6000003814697},{"duration":275.3999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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":285.70000076293945,"connectEnd":285.70000076293945,"connectStart":285.70000076293945,"domainLookupEnd":285.70000076293945,"domainLookupStart":285.70000076293945,"fetchStart":285.70000076293945,"redirectEnd":0,"redirectStart":0,"requestStart":357.70000076293945,"responseEnd":561.1000003814697,"responseStart":373.70000076293945,"secureConnectionStart":285.70000076293945},{"duration":83.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":285.9000005722046,"connectEnd":285.9000005722046,"connectStart":285.9000005722046,"domainLookupEnd":285.9000005722046,"domainLookupStart":285.9000005722046,"fetchStart":285.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":357.80000019073486,"responseEnd":369.4000005722046,"responseStart":368.70000076293945,"secureConnectionStart":285.9000005722046},{"duration":93.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":286.1000003814697,"connectEnd":366.80000019073486,"connectStart":366.80000019073486,"domainLookupEnd":366.80000019073486,"domainLookupStart":366.80000019073486,"fetchStart":286.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":367.30000019073486,"responseEnd":379.6000003814697,"responseStart":378.6000003814697,"secureConnectionStart":366.80000019073486},{"duration":94.29999923706055,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":286.20000076293945,"connectEnd":286.20000076293945,"connectStart":286.20000076293945,"domainLookupEnd":286.20000076293945,"domainLookupStart":286.20000076293945,"fetchStart":286.20000076293945,"redirectEnd":0,"redirectStart":0,"requestStart":368.30000019073486,"responseEnd":380.5,"responseStart":379.70000076293945,"secureConnectionStart":286.20000076293945},{"duration":82.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":286.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":286.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":369,"responseStart":0,"secureConnectionStart":0},{"duration":101.39999961853027,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":286.6000003814697,"connectEnd":286.6000003814697,"connectStart":286.6000003814697,"domainLookupEnd":286.6000003814697,"domainLookupStart":286.6000003814697,"fetchStart":286.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":370.5,"responseEnd":388,"responseStart":385.6000003814697,"secureConnectionStart":286.6000003814697},{"duration":86.19999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/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":286.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":286.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":373,"responseStart":0,"secureConnectionStart":0},{"duration":102.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/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":287,"connectEnd":287,"connectStart":287,"domainLookupEnd":287,"domainLookupStart":287,"fetchStart":287,"redirectEnd":0,"redirectStart":0,"requestStart":371.30000019073486,"responseEnd":389.30000019073486,"responseStart":386.4000005722046,"secureConnectionStart":287},{"duration":630.1999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":298.30000019073486,"connectEnd":298.30000019073486,"connectStart":298.30000019073486,"domainLookupEnd":298.30000019073486,"domainLookupStart":298.30000019073486,"fetchStart":298.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":463.1000003814697,"responseEnd":928.5,"responseStart":918.6000003814697,"secureConnectionStart":298.30000019073486},{"duration":631.6999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":298.30000019073486,"connectEnd":298.30000019073486,"connectStart":298.30000019073486,"domainLookupEnd":298.30000019073486,"domainLookupStart":298.30000019073486,"fetchStart":298.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":511.20000076293945,"responseEnd":930,"responseStart":922.6000003814697,"secureConnectionStart":298.30000019073486},{"duration":243.89999961853027,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":756.9000005722046,"connectEnd":756.9000005722046,"connectStart":756.9000005722046,"domainLookupEnd":756.9000005722046,"domainLookupStart":756.9000005722046,"fetchStart":756.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":935.6000003814697,"responseEnd":1000.8000001907349,"responseStart":999.4000005722046,"secureConnectionStart":756.9000005722046},{"duration":204.5999994277954,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1006.9000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1006.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1211.5,"responseStart":0,"secureConnectionStart":0},{"duration":190.69999980926514,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1038.7000007629395,"connectEnd":1038.7000007629395,"connectStart":1038.7000007629395,"domainLookupEnd":1038.7000007629395,"domainLookupStart":1038.7000007629395,"fetchStart":1038.7000007629395,"redirectEnd":0,"redirectStart":0,"requestStart":1184.1000003814697,"responseEnd":1229.4000005722046,"responseStart":1228.6000003814697,"secureConnectionStart":1038.7000007629395}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":106,"responseStart":279,"responseEnd":296,"domLoading":283,"domInteractive":1176,"domContentLoadedEventStart":1176,"domContentLoadedEventEnd":1211,"domComplete":1606,"loadEventStart":1606,"loadEventEnd":1607,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1158.2000007629395},{"name":"bigPipe.sidebar-id.end","time":1159},{"name":"bigPipe.activity-panel-pipe-id.start","time":1159.1000003814697},{"name":"bigPipe.activity-panel-pipe-id.end","time":1160.5},{"name":"activityTabFullyLoaded","time":1230.2000007629395}],"measures":[],"correlationId":"978376bcc286c6","effectiveType":"4g","downlink":9.1,"rtt":0,"serverDuration":91,"dbReadsTimeInMs":13,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}