Type:
Bug
Priority:
Minor
Resolution:
Won't Fix
Affects Version/s:
None
Component/s:
None
psergey wrote:
For the record: this is happening because Table Elimination uses Field::part_of_key to check whether a field is part of an index.
This is not correct, Field::part_of_key bit is set if the field is a part of an index, and the index is covering.
This means I should fix table elimination. I consider all this low-priority, though.
I have 3 tables (Cassandra, InnoDB, MyISAM) with the same structure and contents (10K rows, load file is attached), and run the same query.
Tables:
mysql> show create table sbtest \G
*************************** 1. row ***************************
Table : sbtest
Create Table : CREATE TABLE `sbtest` (
`rowkey` int (10) unsigned NOT NULL ,
`k` int (10) unsigned NOT NULL DEFAULT '0' ,
`c` char (120) NOT NULL DEFAULT '' ,
`pad` char (60) NOT NULL DEFAULT '' ,
PRIMARY KEY (`rowkey`)
) ENGINE=CASSANDRA DEFAULT CHARSET=latin1 `thrift_host`= 'localhost' `keyspace`= 'sysbench' `column_family`= 'sbtest'
1 row in set (0.00 sec)
mysql> show create table sbtest_inno \G
*************************** 1. row ***************************
Table : sbtest_inno
Create Table : CREATE TABLE `sbtest_inno` (
`rowkey` int (10) unsigned NOT NULL ,
`k` int (10) unsigned NOT NULL DEFAULT '0' ,
`c` char (120) NOT NULL DEFAULT '' ,
`pad` char (60) NOT NULL DEFAULT '' ,
PRIMARY KEY (`rowkey`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
mysql> show create table sbtest_myisam \G
*************************** 1. row ***************************
Table : sbtest_myisam
Create Table : CREATE TABLE `sbtest_myisam` (
`rowkey` int (10) unsigned NOT NULL ,
`k` int (10) unsigned NOT NULL DEFAULT '0' ,
`c` char (120) NOT NULL DEFAULT '' ,
`pad` char (60) NOT NULL DEFAULT '' ,
PRIMARY KEY (`rowkey`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
EXPLAINs:
mysql> explain select s.k from sbtest s left join sbtest t using (rowkey) where s.rowkey>100 and s.rowkey < 120;
+------+-------------+-------+--------+---------------+---------+---------+---------------+------+-----------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+--------+---------------+---------+---------+---------------+------+-----------------------------------------------------+
| 1 | SIMPLE | s | ALL | PRIMARY | NULL | NULL | NULL | 1000 | Using where |
| 1 | SIMPLE | t | eq_ref | PRIMARY | PRIMARY | 4 | test.s.rowkey | 1 | Using join buffer (flat, BKAH join); multiget_slice |
+------+-------------+-------+--------+---------------+---------+---------+---------------+------+-----------------------------------------------------+
2 rows in set (0.00 sec)
mysql> explain select s.k from sbtest_inno s left join sbtest_inno t using (rowkey) where s.rowkey>100 and s.rowkey < 120;
+------+-------------+-------+-------+---------------+---------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+-------+---------------+---------+---------+------+------+-------------+
| 1 | SIMPLE | s | range | PRIMARY | PRIMARY | 4 | NULL | 17 | Using where |
+------+-------------+-------+-------+---------------+---------+---------+------+------+-------------+
1 row in set (0.00 sec)
mysql> explain select s.k from sbtest_myisam s left join sbtest_myisam t using (rowkey) where s.rowkey>100 and s.rowkey < 120;
+------+-------------+-------+-------+---------------+---------+---------+------+------+-----------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+-------+---------------+---------+---------+------+------+-----------------------+
| 1 | SIMPLE | s | range | PRIMARY | PRIMARY | 4 | NULL | 27 | Using index condition |
+------+-------------+-------+-------+---------------+---------+---------+------+------+-----------------------+
1 row in set (0.01 sec)
Non-default join_cache_level:
mysql> select @@join_cache_level;
+--------------------+
| @@join_cache_level |
+--------------------+
| 8 |
+--------------------+
Default optimizer_switch:
mysql> select @@optimizer_switch;
@@optimizer_switch
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=off
Cassandra structures:
CREATE KEYSPACE sysbench WITH strategy_class = 'SimpleStrategy'
AND strategy_options:replication_factor = '1' ;
USE sysbench;
CREATE TABLE sbtest (
id bigint PRIMARY KEY ,
c text,
k bigint ,
pad text
) WITH
comment= '' AND
caching= 'KEYS_ONLY' AND
read_repair_chance=0.100000 AND
gc_grace_seconds=864000 AND
replicate_on_write= 'true' AND
compaction_strategy_class= 'SizeTieredCompactionStrategy' AND
compression_parameters:sstable_compression= 'SnappyCompressor' ;
bzr revno: 3495
relates to
MDEV-431
Cassandra storage engine
Closed
{"report":{"fcp":939.8999999761581,"ttfb":201.10000002384186,"pageVisibility":"visible","entityId":13910,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"95032c69-e353-459f-b046-1212bacd8574","navigationType":0,"readyForUser":1101.1000000238419,"redirectCount":0,"resourceLoadedEnd":732.6999999284744,"resourceLoadedStart":207.60000002384186,"resourceTiming":[{"duration":281.7999999523163,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":207.60000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":207.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":489.39999997615814,"responseStart":0,"secureConnectionStart":0},{"duration":281.60000002384186,"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":207.89999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":207.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":489.5,"responseStart":0,"secureConnectionStart":0},{"duration":290.6999999284744,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":208,"connectEnd":208,"connectStart":208,"domainLookupEnd":208,"domainLookupStart":208,"fetchStart":208,"redirectEnd":0,"redirectStart":0,"requestStart":208,"responseEnd":498.6999999284744,"responseStart":498.6999999284744,"secureConnectionStart":208},{"duration":315.59999990463257,"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":208.10000002384186,"connectEnd":208.10000002384186,"connectStart":208.10000002384186,"domainLookupEnd":208.10000002384186,"domainLookupStart":208.10000002384186,"fetchStart":208.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":208.10000002384186,"responseEnd":523.6999999284744,"responseStart":523.6999999284744,"secureConnectionStart":208.10000002384186},{"duration":319.10000002384186,"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":208.19999992847443,"connectEnd":208.19999992847443,"connectStart":208.19999992847443,"domainLookupEnd":208.19999992847443,"domainLookupStart":208.19999992847443,"fetchStart":208.19999992847443,"redirectEnd":0,"redirectStart":0,"requestStart":208.19999992847443,"responseEnd":527.2999999523163,"responseStart":527.2999999523163,"secureConnectionStart":208.19999992847443},{"duration":319.39999997615814,"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":208.29999995231628,"connectEnd":208.29999995231628,"connectStart":208.29999995231628,"domainLookupEnd":208.29999995231628,"domainLookupStart":208.29999995231628,"fetchStart":208.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":208.29999995231628,"responseEnd":527.6999999284744,"responseStart":527.6999999284744,"secureConnectionStart":208.29999995231628},{"duration":319.7000000476837,"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":208.39999997615814,"connectEnd":208.39999997615814,"connectStart":208.39999997615814,"domainLookupEnd":208.39999997615814,"domainLookupStart":208.39999997615814,"fetchStart":208.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":208.39999997615814,"responseEnd":528.1000000238419,"responseStart":528.1000000238419,"secureConnectionStart":208.39999997615814},{"duration":320.89999997615814,"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":208.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":208.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":529.3999999761581,"responseStart":0,"secureConnectionStart":0},{"duration":319.7999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":208.60000002384186,"connectEnd":208.60000002384186,"connectStart":208.60000002384186,"domainLookupEnd":208.60000002384186,"domainLookupStart":208.60000002384186,"fetchStart":208.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":208.60000002384186,"responseEnd":528.3999999761581,"responseStart":528.3999999761581,"secureConnectionStart":208.60000002384186},{"duration":320.8000000715256,"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":208.79999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":208.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":529.6000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":320,"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":209,"connectEnd":209,"connectStart":209,"domainLookupEnd":209,"domainLookupStart":209,"fetchStart":209,"redirectEnd":0,"redirectStart":0,"requestStart":209,"responseEnd":529,"responseStart":529,"secureConnectionStart":209},{"duration":399.3000000715256,"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":209.69999992847443,"connectEnd":209.69999992847443,"connectStart":209.69999992847443,"domainLookupEnd":209.69999992847443,"domainLookupStart":209.69999992847443,"fetchStart":209.69999992847443,"redirectEnd":0,"redirectStart":0,"requestStart":209.69999992847443,"responseEnd":609,"responseStart":609,"secureConnectionStart":209.69999992847443},{"duration":522.8999999761581,"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":209.79999995231628,"connectEnd":209.79999995231628,"connectStart":209.79999995231628,"domainLookupEnd":209.79999995231628,"domainLookupStart":209.79999995231628,"fetchStart":209.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":209.79999995231628,"responseEnd":732.6999999284744,"responseStart":732.6999999284744,"secureConnectionStart":209.79999995231628},{"duration":317.7000000476837,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":736.3999999761581,"connectEnd":736.3999999761581,"connectStart":736.3999999761581,"domainLookupEnd":736.3999999761581,"domainLookupStart":736.3999999761581,"fetchStart":736.3999999761581,"redirectEnd":0,"redirectStart":0,"requestStart":736.3999999761581,"responseEnd":1054.1000000238419,"responseStart":1054.1000000238419,"secureConnectionStart":736.3999999761581},{"duration":252,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":917.8999999761581,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":917.8999999761581,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1169.8999999761581,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":51,"responseStart":201,"responseEnd":205,"domLoading":205,"domInteractive":1160,"domContentLoadedEventStart":1160,"domContentLoadedEventEnd":1201,"domComplete":1970,"loadEventStart":1970,"loadEventEnd":1972,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1127.8999999761581},{"name":"bigPipe.sidebar-id.end","time":1133.6999999284744},{"name":"bigPipe.activity-panel-pipe-id.start","time":1133.8999999761581},{"name":"bigPipe.activity-panel-pipe-id.end","time":1137},{"name":"activityTabFullyLoaded","time":1210.7999999523163}],"measures":[],"correlationId":"8aaf410a22426c","effectiveType":"4g","downlink":9.7,"rtt":0,"serverDuration":78,"dbReadsTimeInMs":10,"dbConnsTimeInMs":17,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}