create table ten(a int);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1(key1 int, col1 int, key(key1));
insert into t1 select A.a, A.a from ten A, ten B, ten C;
set histogram_size=100;
set use_stat_tables='preferably';
set optimizer_use_condition_selectivity=4;
analyze table t1 persistent for all;
mysql> explain extended select * from t1 where col1=2;
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
| 1 | SIMPLE | t1 | ALL | NULL | NULL | NULL | NULL | 1000 | 9.90 | Using where |
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
This is ok.
mysql> explain extended select * from t1 where key1=2;
+------+-------------+-------+------+---------------+------+---------+-------+------+----------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+------+-------------+-------+------+---------------+------+---------+-------+------+----------+-------+
| 1 | SIMPLE | t1 | ref | key1 | key1 | 5 | const | 100 | 10.00 | |
+------+-------------+-------+------+---------------+------+---------+-------+------+----------+-------+
This is not ok. "key1=2" is used for ref access. However, its selectivity is still present in "filtered%". Ref access is employed when a condition is very selective, counting its selectivity twice will cause gross under-estimation of output cardinality.
Sergei Petrunia
made changes -
2014-03-29 00:04
Field
Original Value
New Value
Assignee
Igor Babaev
[ igor
]
Sergei Petrunia
made changes -
2014-03-29 00:05
Assignee
Igor Babaev
[ igor
]
Sergei Petrunia
[ psergey
]
Sergei Petrunia
made changes -
2014-03-29 00:05
Status
Open
[ 1
]
In Progress
[ 3
]
Sergei Petrunia
made changes -
2014-03-29 00:07
Description
{noformat}
create table ten(a int);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1(key1 int, col1 int, key(key1));
insert into t1 select A.a, A.a from ten A, ten B, ten C;
set histogram_size=100;
set use_stat_tables='preferably';
set optimizer_use_condition_selectivity=4;
analyze table t1 persistent for all;
{noformat}
{noformat}
mysql> explain extended select * from t1 where col1=2;
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
| 1 | SIMPLE | t1 | ALL | NULL | NULL | NULL | NULL | 1000 | 9.90 | Using where |
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
{noformat}
{noformat}
mysql> explain extended select * from t1 where key1=2;
+------+-------------+-------+------+---------------+------+---------+-------+------+----------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+------+-------------+-------+------+---------------+------+---------+-------+------+----------+-------+
| 1 | SIMPLE | t1 | ref | key1 | key1 | 5 | const | 100 | 10.00 | |
+------+-------------+-------+------+---------------+------+---------+-------+------+----------+-------+
{noformat}
{noformat}
create table ten(a int);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1(key1 int, col1 int, key(key1));
insert into t1 select A.a, A.a from ten A, ten B, ten C;
set histogram_size=100;
set use_stat_tables='preferably';
set optimizer_use_condition_selectivity=4;
analyze table t1 persistent for all;
{noformat}
{noformat}
mysql> explain extended select * from t1 where col1=2;
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
| 1 | SIMPLE | t1 | ALL | NULL | NULL | NULL | NULL | 1000 | 9.90 | Using where |
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
{noformat}
This is ok.
{noformat}
mysql> explain extended select * from t1 where key1=2;
+------+-------------+-------+------+---------------+------+---------+-------+------+----------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+------+-------------+-------+------+---------------+------+---------+-------+------+----------+-------+
| 1 | SIMPLE | t1 | ref | key1 | key1 | 5 | const | 100 | 10.00 | |
+------+-------------+-------+------+---------------+------+---------+-------+------+----------+-------+
{noformat}
This is not ok. "key1=2" is used for ref access. However, its selectivity is still present in "filtered%". Ref access is employed when a condition is very selective, counting its selectivity twice will cause gross under-estimation of output cardinality.
Sergei Golubchik
made changes -
2014-03-31 14:23
Fix Version/s
10.0.11
[ 15200
]
Fix Version/s
10.0.10
[ 14500
]
Sergei Petrunia
made changes -
2014-04-28 20:56
Resolution
Fixed
[ 1
]
Status
In Progress
[ 3
]
Closed
[ 6
]
Sergei Golubchik
made changes -
2014-06-13 15:06
Workflow
defaullt
[ 37802
]
MariaDB v2
[ 43654
]
Sergei Golubchik
made changes -
2021-12-06 21:39
Workflow
MariaDB v3
[ 63682
]
MariaDB v4
[ 147719
]
{"report":{"fcp":1610.7999999523163,"ttfb":440.90000009536743,"pageVisibility":"visible","entityId":34002,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"a9759f74-e52d-49e6-aa89-f72fd352bd04","navigationType":0,"readyForUser":1640.7999999523163,"redirectCount":0,"resourceLoadedEnd":1974.6000001430511,"resourceLoadedStart":504.7999999523163,"resourceTiming":[{"duration":131.70000004768372,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":504.7999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":504.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":636.5,"responseStart":0,"secureConnectionStart":0},{"duration":131.69999980926514,"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":505.10000014305115,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":505.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":636.7999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":190.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":505.2999999523163,"connectEnd":505.2999999523163,"connectStart":505.2999999523163,"domainLookupEnd":505.2999999523163,"domainLookupStart":505.2999999523163,"fetchStart":505.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":505.2999999523163,"responseEnd":695.7000000476837,"responseStart":695.7000000476837,"secureConnectionStart":505.2999999523163},{"duration":691.1000001430511,"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":505.5,"connectEnd":505.5,"connectStart":505.5,"domainLookupEnd":505.5,"domainLookupStart":505.5,"fetchStart":505.5,"redirectEnd":0,"redirectStart":0,"requestStart":505.5,"responseEnd":1196.6000001430511,"responseStart":1196.6000001430511,"secureConnectionStart":505.5},{"duration":694.9000000953674,"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":505.7999999523163,"connectEnd":505.7999999523163,"connectStart":505.7999999523163,"domainLookupEnd":505.7999999523163,"domainLookupStart":505.7999999523163,"fetchStart":505.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":505.7999999523163,"responseEnd":1200.7000000476837,"responseStart":1200.7000000476837,"secureConnectionStart":505.7999999523163},{"duration":695.2000000476837,"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":506,"connectEnd":506,"connectStart":506,"domainLookupEnd":506,"domainLookupStart":506,"fetchStart":506,"redirectEnd":0,"redirectStart":0,"requestStart":506,"responseEnd":1201.2000000476837,"responseStart":1201.2000000476837,"secureConnectionStart":506},{"duration":695.5,"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":506.2000000476837,"connectEnd":506.2000000476837,"connectStart":506.2000000476837,"domainLookupEnd":506.2000000476837,"domainLookupStart":506.2000000476837,"fetchStart":506.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":506.2000000476837,"responseEnd":1201.7000000476837,"responseStart":1201.7000000476837,"secureConnectionStart":506.2000000476837},{"duration":696.4000000953674,"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":506.2999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":506.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1202.7000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":695.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":506.60000014305115,"connectEnd":506.60000014305115,"connectStart":506.60000014305115,"domainLookupEnd":506.60000014305115,"domainLookupStart":506.60000014305115,"fetchStart":506.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":506.60000014305115,"responseEnd":1202.1000001430511,"responseStart":1202.1000001430511,"secureConnectionStart":506.60000014305115},{"duration":696,"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":506.7999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":506.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1202.7999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":695.9000000953674,"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":506.7999999523163,"connectEnd":506.7999999523163,"connectStart":506.7999999523163,"domainLookupEnd":506.7999999523163,"domainLookupStart":506.7999999523163,"fetchStart":506.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":506.7999999523163,"responseEnd":1202.7000000476837,"responseStart":1202.7000000476837,"secureConnectionStart":506.7999999523163},{"duration":1256.9000000953674,"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":507.7000000476837,"connectEnd":507.7000000476837,"connectStart":507.7000000476837,"domainLookupEnd":507.7000000476837,"domainLookupStart":507.7000000476837,"fetchStart":507.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":507.7000000476837,"responseEnd":1764.6000001430511,"responseStart":1764.6000001430511,"secureConnectionStart":507.7000000476837},{"duration":1462.2000000476837,"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":512.4000000953674,"connectEnd":512.4000000953674,"connectStart":512.4000000953674,"domainLookupEnd":512.4000000953674,"domainLookupStart":512.4000000953674,"fetchStart":512.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":512.4000000953674,"responseEnd":1974.6000001430511,"responseStart":1974.6000001430511,"secureConnectionStart":512.4000000953674},{"duration":821.1999998092651,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":861.6000001430511,"connectEnd":861.6000001430511,"connectStart":861.6000001430511,"domainLookupEnd":861.6000001430511,"domainLookupStart":861.6000001430511,"fetchStart":861.6000001430511,"redirectEnd":0,"redirectStart":0,"requestStart":861.6000001430511,"responseEnd":1682.7999999523163,"responseStart":1682.7999999523163,"secureConnectionStart":861.6000001430511},{"duration":465.5,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1550.9000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1550.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2016.4000000953674,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":245,"responseStart":441,"responseEnd":512,"domLoading":446,"domInteractive":2046,"domContentLoadedEventStart":2047,"domContentLoadedEventEnd":2101,"domComplete":2868,"loadEventStart":2868,"loadEventEnd":2869,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":2017.4000000953674},{"name":"bigPipe.sidebar-id.end","time":2018.2999999523163},{"name":"bigPipe.activity-panel-pipe-id.start","time":2018.5},{"name":"bigPipe.activity-panel-pipe-id.end","time":2021.2000000476837},{"name":"activityTabFullyLoaded","time":2118.2000000476837}],"measures":[],"correlationId":"d85cd5eae2f85b","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":134,"dbReadsTimeInMs":22,"dbConnsTimeInMs":31,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}