Cassandra row caching not working when table has composite primary key











up vote
0
down vote

favorite












Row caching only works if the table has a single column primary key otherwise if you add a clustering key to the table then row caching no longer works. The Cassandra version I've tested this against is 3.11.0 but the issue is also evident in 3.11.3 which is the latest one at the time of writing this.



I am using the default Cassandra configs plus:



key_cache_size_in_mb:
key_cache_save_period: 14400
row_cache_size_in_mb: 128
row_cache_save_period: 14400


It looks like a very fundamental feature so I am not quite sure whether this is a bug or something that I am missing:



cqlsh> CREATE TABLE test.table1 (k text, v text, PRIMARY KEY (k)) WITH caching = {'keys': 'ALL', 'rows_per_partition': '100'};
cqlsh> CREATE TABLE test.table2 (k text, v text, PRIMARY KEY (k, v)) WITH caching = {'keys': 'ALL', 'rows_per_partition': '100'};
cqlsh> insert into test.table1 (k,v) values('k1', 'v1');
cqlsh> insert into test.table2 (k,v) values('k1', 'v1');
cqlsh> tracing on;
Now Tracing is enabled
cqlsh> select * from test.table1 where k='k1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: e81f1640-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
-----------------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:22:44.004000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table1 where k='k1'; [Native-Transport-Requests-1] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 225 | 127.0.0.1
Preparing statement [Native-Transport-Requests-1] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 395 | 127.0.0.1
Row cache miss [ReadStage-3] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 930 | 127.0.0.1
Executing single-partition query on table1 [ReadStage-3] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 1047 | 127.0.0.1
Acquiring sstable references [ReadStage-3] | 2018-11-19 07:22:44.006000 | 127.0.0.1 | 1106 | 127.0.0.1
Skipped 0/0 non-slice-intersecting sstables, included 0 due to tombstones [ReadStage-3] | 2018-11-19 07:22:44.006000 | 127.0.0.1 | 1180 | 127.0.0.1
Caching 1 rows [ReadStage-3] | 2018-11-19 07:22:44.006000 | 127.0.0.1 | 1282 | 127.0.0.1
Merged data from memtables and 0 sstables [ReadStage-3] | 2018-11-19 07:22:44.006001 | 127.0.0.1 | 1529 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-3] | 2018-11-19 07:22:44.006001 | 127.0.0.1 | 1670 | 127.0.0.1
Request complete | 2018-11-19 07:22:44.005903 | 127.0.0.1 | 1903 | 127.0.0.1


cqlsh> select * from test.table1 where k='k1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: edf0cd70-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:22:53.767000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table1 where k='k1'; [Native-Transport-Requests-1] | 2018-11-19 07:22:53.767000 | 127.0.0.1 | 160 | 127.0.0.1
Preparing statement [Native-Transport-Requests-1] | 2018-11-19 07:22:53.767000 | 127.0.0.1 | 335 | 127.0.0.1
Row cache hit [ReadStage-3] | 2018-11-19 07:22:53.768000 | 127.0.0.1 | 915 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-3] | 2018-11-19 07:22:53.768000 | 127.0.0.1 | 1066 | 127.0.0.1
Request complete | 2018-11-19 07:22:53.768255 | 127.0.0.1 | 1255 | 127.0.0.1


cqlsh> select * from test.table2 where k='k1' and v='v1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: f7c26200-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
--------------------------------------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:23:10.240000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table2 where k='k1' and v='v1'; [Native-Transport-Requests-1] | 2018-11-19 07:23:10.240000 | 127.0.0.1 | 168 | 127.0.0.1
Preparing statement [Native-Transport-Requests-1] | 2018-11-19 07:23:10.240000 | 127.0.0.1 | 343 | 127.0.0.1
Row cache miss [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 824 | 127.0.0.1
Fetching data but not populating cache as query does not query from the start of the partition [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 891 | 127.0.0.1
Executing single-partition query on table2 [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 923 | 127.0.0.1
Acquiring sstable references [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 949 | 127.0.0.1
Merging memtable contents [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 978 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 1132 | 127.0.0.1
Request complete | 2018-11-19 07:23:10.241338 | 127.0.0.1 | 1338 | 127.0.0.1


cqlsh> select * from test.table2 where k='k1' and v='v1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: f9d6c310-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
--------------------------------------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:23:13.729000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table2 where k='k1' and v='v1'; [Native-Transport-Requests-2] | 2018-11-19 07:23:13.729000 | 127.0.0.1 | 182 | 127.0.0.1
Preparing statement [Native-Transport-Requests-2] | 2018-11-19 07:23:13.729000 | 127.0.0.1 | 355 | 127.0.0.1
Row cache miss [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 839 | 127.0.0.1
Fetching data but not populating cache as query does not query from the start of the partition [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 902 | 127.0.0.1
Executing single-partition query on table2 [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 942 | 127.0.0.1
Acquiring sstable references [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 967 | 127.0.0.1
Merging memtable contents [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 992 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 1116 | 127.0.0.1
Request complete | 2018-11-19 07:23:13.730307 | 127.0.0.1 | 1307 | 127.0.0.1


Looking at the tracing log it seems that rows with clustering keys might not be cachable - Fetching data but not populating cache as query does not query from the start of the partition?










share|improve this question
























  • Looks like you might have hit this issue: issues.apache.org/jira/browse/CASSANDRA-8646
    – Justin Cameron
    Nov 20 at 3:18















up vote
0
down vote

favorite












Row caching only works if the table has a single column primary key otherwise if you add a clustering key to the table then row caching no longer works. The Cassandra version I've tested this against is 3.11.0 but the issue is also evident in 3.11.3 which is the latest one at the time of writing this.



I am using the default Cassandra configs plus:



key_cache_size_in_mb:
key_cache_save_period: 14400
row_cache_size_in_mb: 128
row_cache_save_period: 14400


It looks like a very fundamental feature so I am not quite sure whether this is a bug or something that I am missing:



cqlsh> CREATE TABLE test.table1 (k text, v text, PRIMARY KEY (k)) WITH caching = {'keys': 'ALL', 'rows_per_partition': '100'};
cqlsh> CREATE TABLE test.table2 (k text, v text, PRIMARY KEY (k, v)) WITH caching = {'keys': 'ALL', 'rows_per_partition': '100'};
cqlsh> insert into test.table1 (k,v) values('k1', 'v1');
cqlsh> insert into test.table2 (k,v) values('k1', 'v1');
cqlsh> tracing on;
Now Tracing is enabled
cqlsh> select * from test.table1 where k='k1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: e81f1640-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
-----------------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:22:44.004000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table1 where k='k1'; [Native-Transport-Requests-1] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 225 | 127.0.0.1
Preparing statement [Native-Transport-Requests-1] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 395 | 127.0.0.1
Row cache miss [ReadStage-3] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 930 | 127.0.0.1
Executing single-partition query on table1 [ReadStage-3] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 1047 | 127.0.0.1
Acquiring sstable references [ReadStage-3] | 2018-11-19 07:22:44.006000 | 127.0.0.1 | 1106 | 127.0.0.1
Skipped 0/0 non-slice-intersecting sstables, included 0 due to tombstones [ReadStage-3] | 2018-11-19 07:22:44.006000 | 127.0.0.1 | 1180 | 127.0.0.1
Caching 1 rows [ReadStage-3] | 2018-11-19 07:22:44.006000 | 127.0.0.1 | 1282 | 127.0.0.1
Merged data from memtables and 0 sstables [ReadStage-3] | 2018-11-19 07:22:44.006001 | 127.0.0.1 | 1529 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-3] | 2018-11-19 07:22:44.006001 | 127.0.0.1 | 1670 | 127.0.0.1
Request complete | 2018-11-19 07:22:44.005903 | 127.0.0.1 | 1903 | 127.0.0.1


cqlsh> select * from test.table1 where k='k1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: edf0cd70-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:22:53.767000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table1 where k='k1'; [Native-Transport-Requests-1] | 2018-11-19 07:22:53.767000 | 127.0.0.1 | 160 | 127.0.0.1
Preparing statement [Native-Transport-Requests-1] | 2018-11-19 07:22:53.767000 | 127.0.0.1 | 335 | 127.0.0.1
Row cache hit [ReadStage-3] | 2018-11-19 07:22:53.768000 | 127.0.0.1 | 915 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-3] | 2018-11-19 07:22:53.768000 | 127.0.0.1 | 1066 | 127.0.0.1
Request complete | 2018-11-19 07:22:53.768255 | 127.0.0.1 | 1255 | 127.0.0.1


cqlsh> select * from test.table2 where k='k1' and v='v1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: f7c26200-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
--------------------------------------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:23:10.240000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table2 where k='k1' and v='v1'; [Native-Transport-Requests-1] | 2018-11-19 07:23:10.240000 | 127.0.0.1 | 168 | 127.0.0.1
Preparing statement [Native-Transport-Requests-1] | 2018-11-19 07:23:10.240000 | 127.0.0.1 | 343 | 127.0.0.1
Row cache miss [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 824 | 127.0.0.1
Fetching data but not populating cache as query does not query from the start of the partition [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 891 | 127.0.0.1
Executing single-partition query on table2 [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 923 | 127.0.0.1
Acquiring sstable references [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 949 | 127.0.0.1
Merging memtable contents [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 978 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 1132 | 127.0.0.1
Request complete | 2018-11-19 07:23:10.241338 | 127.0.0.1 | 1338 | 127.0.0.1


cqlsh> select * from test.table2 where k='k1' and v='v1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: f9d6c310-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
--------------------------------------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:23:13.729000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table2 where k='k1' and v='v1'; [Native-Transport-Requests-2] | 2018-11-19 07:23:13.729000 | 127.0.0.1 | 182 | 127.0.0.1
Preparing statement [Native-Transport-Requests-2] | 2018-11-19 07:23:13.729000 | 127.0.0.1 | 355 | 127.0.0.1
Row cache miss [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 839 | 127.0.0.1
Fetching data but not populating cache as query does not query from the start of the partition [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 902 | 127.0.0.1
Executing single-partition query on table2 [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 942 | 127.0.0.1
Acquiring sstable references [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 967 | 127.0.0.1
Merging memtable contents [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 992 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 1116 | 127.0.0.1
Request complete | 2018-11-19 07:23:13.730307 | 127.0.0.1 | 1307 | 127.0.0.1


Looking at the tracing log it seems that rows with clustering keys might not be cachable - Fetching data but not populating cache as query does not query from the start of the partition?










share|improve this question
























  • Looks like you might have hit this issue: issues.apache.org/jira/browse/CASSANDRA-8646
    – Justin Cameron
    Nov 20 at 3:18













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Row caching only works if the table has a single column primary key otherwise if you add a clustering key to the table then row caching no longer works. The Cassandra version I've tested this against is 3.11.0 but the issue is also evident in 3.11.3 which is the latest one at the time of writing this.



I am using the default Cassandra configs plus:



key_cache_size_in_mb:
key_cache_save_period: 14400
row_cache_size_in_mb: 128
row_cache_save_period: 14400


It looks like a very fundamental feature so I am not quite sure whether this is a bug or something that I am missing:



cqlsh> CREATE TABLE test.table1 (k text, v text, PRIMARY KEY (k)) WITH caching = {'keys': 'ALL', 'rows_per_partition': '100'};
cqlsh> CREATE TABLE test.table2 (k text, v text, PRIMARY KEY (k, v)) WITH caching = {'keys': 'ALL', 'rows_per_partition': '100'};
cqlsh> insert into test.table1 (k,v) values('k1', 'v1');
cqlsh> insert into test.table2 (k,v) values('k1', 'v1');
cqlsh> tracing on;
Now Tracing is enabled
cqlsh> select * from test.table1 where k='k1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: e81f1640-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
-----------------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:22:44.004000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table1 where k='k1'; [Native-Transport-Requests-1] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 225 | 127.0.0.1
Preparing statement [Native-Transport-Requests-1] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 395 | 127.0.0.1
Row cache miss [ReadStage-3] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 930 | 127.0.0.1
Executing single-partition query on table1 [ReadStage-3] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 1047 | 127.0.0.1
Acquiring sstable references [ReadStage-3] | 2018-11-19 07:22:44.006000 | 127.0.0.1 | 1106 | 127.0.0.1
Skipped 0/0 non-slice-intersecting sstables, included 0 due to tombstones [ReadStage-3] | 2018-11-19 07:22:44.006000 | 127.0.0.1 | 1180 | 127.0.0.1
Caching 1 rows [ReadStage-3] | 2018-11-19 07:22:44.006000 | 127.0.0.1 | 1282 | 127.0.0.1
Merged data from memtables and 0 sstables [ReadStage-3] | 2018-11-19 07:22:44.006001 | 127.0.0.1 | 1529 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-3] | 2018-11-19 07:22:44.006001 | 127.0.0.1 | 1670 | 127.0.0.1
Request complete | 2018-11-19 07:22:44.005903 | 127.0.0.1 | 1903 | 127.0.0.1


cqlsh> select * from test.table1 where k='k1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: edf0cd70-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:22:53.767000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table1 where k='k1'; [Native-Transport-Requests-1] | 2018-11-19 07:22:53.767000 | 127.0.0.1 | 160 | 127.0.0.1
Preparing statement [Native-Transport-Requests-1] | 2018-11-19 07:22:53.767000 | 127.0.0.1 | 335 | 127.0.0.1
Row cache hit [ReadStage-3] | 2018-11-19 07:22:53.768000 | 127.0.0.1 | 915 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-3] | 2018-11-19 07:22:53.768000 | 127.0.0.1 | 1066 | 127.0.0.1
Request complete | 2018-11-19 07:22:53.768255 | 127.0.0.1 | 1255 | 127.0.0.1


cqlsh> select * from test.table2 where k='k1' and v='v1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: f7c26200-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
--------------------------------------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:23:10.240000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table2 where k='k1' and v='v1'; [Native-Transport-Requests-1] | 2018-11-19 07:23:10.240000 | 127.0.0.1 | 168 | 127.0.0.1
Preparing statement [Native-Transport-Requests-1] | 2018-11-19 07:23:10.240000 | 127.0.0.1 | 343 | 127.0.0.1
Row cache miss [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 824 | 127.0.0.1
Fetching data but not populating cache as query does not query from the start of the partition [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 891 | 127.0.0.1
Executing single-partition query on table2 [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 923 | 127.0.0.1
Acquiring sstable references [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 949 | 127.0.0.1
Merging memtable contents [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 978 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 1132 | 127.0.0.1
Request complete | 2018-11-19 07:23:10.241338 | 127.0.0.1 | 1338 | 127.0.0.1


cqlsh> select * from test.table2 where k='k1' and v='v1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: f9d6c310-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
--------------------------------------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:23:13.729000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table2 where k='k1' and v='v1'; [Native-Transport-Requests-2] | 2018-11-19 07:23:13.729000 | 127.0.0.1 | 182 | 127.0.0.1
Preparing statement [Native-Transport-Requests-2] | 2018-11-19 07:23:13.729000 | 127.0.0.1 | 355 | 127.0.0.1
Row cache miss [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 839 | 127.0.0.1
Fetching data but not populating cache as query does not query from the start of the partition [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 902 | 127.0.0.1
Executing single-partition query on table2 [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 942 | 127.0.0.1
Acquiring sstable references [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 967 | 127.0.0.1
Merging memtable contents [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 992 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 1116 | 127.0.0.1
Request complete | 2018-11-19 07:23:13.730307 | 127.0.0.1 | 1307 | 127.0.0.1


Looking at the tracing log it seems that rows with clustering keys might not be cachable - Fetching data but not populating cache as query does not query from the start of the partition?










share|improve this question















Row caching only works if the table has a single column primary key otherwise if you add a clustering key to the table then row caching no longer works. The Cassandra version I've tested this against is 3.11.0 but the issue is also evident in 3.11.3 which is the latest one at the time of writing this.



I am using the default Cassandra configs plus:



key_cache_size_in_mb:
key_cache_save_period: 14400
row_cache_size_in_mb: 128
row_cache_save_period: 14400


It looks like a very fundamental feature so I am not quite sure whether this is a bug or something that I am missing:



cqlsh> CREATE TABLE test.table1 (k text, v text, PRIMARY KEY (k)) WITH caching = {'keys': 'ALL', 'rows_per_partition': '100'};
cqlsh> CREATE TABLE test.table2 (k text, v text, PRIMARY KEY (k, v)) WITH caching = {'keys': 'ALL', 'rows_per_partition': '100'};
cqlsh> insert into test.table1 (k,v) values('k1', 'v1');
cqlsh> insert into test.table2 (k,v) values('k1', 'v1');
cqlsh> tracing on;
Now Tracing is enabled
cqlsh> select * from test.table1 where k='k1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: e81f1640-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
-----------------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:22:44.004000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table1 where k='k1'; [Native-Transport-Requests-1] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 225 | 127.0.0.1
Preparing statement [Native-Transport-Requests-1] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 395 | 127.0.0.1
Row cache miss [ReadStage-3] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 930 | 127.0.0.1
Executing single-partition query on table1 [ReadStage-3] | 2018-11-19 07:22:44.005000 | 127.0.0.1 | 1047 | 127.0.0.1
Acquiring sstable references [ReadStage-3] | 2018-11-19 07:22:44.006000 | 127.0.0.1 | 1106 | 127.0.0.1
Skipped 0/0 non-slice-intersecting sstables, included 0 due to tombstones [ReadStage-3] | 2018-11-19 07:22:44.006000 | 127.0.0.1 | 1180 | 127.0.0.1
Caching 1 rows [ReadStage-3] | 2018-11-19 07:22:44.006000 | 127.0.0.1 | 1282 | 127.0.0.1
Merged data from memtables and 0 sstables [ReadStage-3] | 2018-11-19 07:22:44.006001 | 127.0.0.1 | 1529 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-3] | 2018-11-19 07:22:44.006001 | 127.0.0.1 | 1670 | 127.0.0.1
Request complete | 2018-11-19 07:22:44.005903 | 127.0.0.1 | 1903 | 127.0.0.1


cqlsh> select * from test.table1 where k='k1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: edf0cd70-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:22:53.767000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table1 where k='k1'; [Native-Transport-Requests-1] | 2018-11-19 07:22:53.767000 | 127.0.0.1 | 160 | 127.0.0.1
Preparing statement [Native-Transport-Requests-1] | 2018-11-19 07:22:53.767000 | 127.0.0.1 | 335 | 127.0.0.1
Row cache hit [ReadStage-3] | 2018-11-19 07:22:53.768000 | 127.0.0.1 | 915 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-3] | 2018-11-19 07:22:53.768000 | 127.0.0.1 | 1066 | 127.0.0.1
Request complete | 2018-11-19 07:22:53.768255 | 127.0.0.1 | 1255 | 127.0.0.1


cqlsh> select * from test.table2 where k='k1' and v='v1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: f7c26200-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
--------------------------------------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:23:10.240000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table2 where k='k1' and v='v1'; [Native-Transport-Requests-1] | 2018-11-19 07:23:10.240000 | 127.0.0.1 | 168 | 127.0.0.1
Preparing statement [Native-Transport-Requests-1] | 2018-11-19 07:23:10.240000 | 127.0.0.1 | 343 | 127.0.0.1
Row cache miss [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 824 | 127.0.0.1
Fetching data but not populating cache as query does not query from the start of the partition [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 891 | 127.0.0.1
Executing single-partition query on table2 [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 923 | 127.0.0.1
Acquiring sstable references [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 949 | 127.0.0.1
Merging memtable contents [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 978 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-2] | 2018-11-19 07:23:10.241000 | 127.0.0.1 | 1132 | 127.0.0.1
Request complete | 2018-11-19 07:23:10.241338 | 127.0.0.1 | 1338 | 127.0.0.1


cqlsh> select * from test.table2 where k='k1' and v='v1';

k | v
----+----
k1 | v1

(1 rows)

Tracing session: f9d6c310-ebcb-11e8-b19a-8f0e04450cb9

activity | timestamp | source | source_elapsed | client
--------------------------------------------------------------------------------------------------------------+----------------------------+-----------+----------------+-----------
Execute CQL3 query | 2018-11-19 07:23:13.729000 | 127.0.0.1 | 0 | 127.0.0.1
Parsing select * from test.table2 where k='k1' and v='v1'; [Native-Transport-Requests-2] | 2018-11-19 07:23:13.729000 | 127.0.0.1 | 182 | 127.0.0.1
Preparing statement [Native-Transport-Requests-2] | 2018-11-19 07:23:13.729000 | 127.0.0.1 | 355 | 127.0.0.1
Row cache miss [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 839 | 127.0.0.1
Fetching data but not populating cache as query does not query from the start of the partition [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 902 | 127.0.0.1
Executing single-partition query on table2 [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 942 | 127.0.0.1
Acquiring sstable references [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 967 | 127.0.0.1
Merging memtable contents [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 992 | 127.0.0.1
Read 1 live and 0 tombstone cells [ReadStage-3] | 2018-11-19 07:23:13.730000 | 127.0.0.1 | 1116 | 127.0.0.1
Request complete | 2018-11-19 07:23:13.730307 | 127.0.0.1 | 1307 | 127.0.0.1


Looking at the tracing log it seems that rows with clustering keys might not be cachable - Fetching data but not populating cache as query does not query from the start of the partition?







cassandra cassandra-3.0






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 at 10:51

























asked Nov 19 at 7:41









Todor Kolev

639721




639721












  • Looks like you might have hit this issue: issues.apache.org/jira/browse/CASSANDRA-8646
    – Justin Cameron
    Nov 20 at 3:18


















  • Looks like you might have hit this issue: issues.apache.org/jira/browse/CASSANDRA-8646
    – Justin Cameron
    Nov 20 at 3:18
















Looks like you might have hit this issue: issues.apache.org/jira/browse/CASSANDRA-8646
– Justin Cameron
Nov 20 at 3:18




Looks like you might have hit this issue: issues.apache.org/jira/browse/CASSANDRA-8646
– Justin Cameron
Nov 20 at 3:18

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53370257%2fcassandra-row-caching-not-working-when-table-has-composite-primary-key%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53370257%2fcassandra-row-caching-not-working-when-table-has-composite-primary-key%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]