Row caches and query paging help improve the performance of Cassandra when running
queries that return large result sets.
Optimize the performance of the queries in Playlist by enabling row caching and using
paging in the queries that return large data sets.
The location of the
cassandra.yaml file depends on
the type of installation:
Package installations |
/etc/cassandra/cassandra.yaml |
Tarball installations |
install_location/resources/cassandra/conf/cassandra.yaml |
Procedure
-
In a terminal, go to the playlist workspace.
-
Check out the
step6
branch using git.
-
Run the cqlsh command.
-
In the
playlist
keyspace alter the
tracks_by_genre
and tracks_by_artist
tables to cache the first 100 rows in the partition.
use playlist;
ALTER TABLE track_by_genre WITH caching = {'rows_per_partition':'100'};
ALTER TABLE track_by_artist WITH caching = {'rows_per_partition':'100'};
-
Quit cqlsh.
-
Using a text editor, modify the
row_cache_size_in_mb
option in
to enable the row cache and set
the amount of memory in the row cache to 50 MB.
# Default value is 0, to disable row caching.
row_cache_size_in_mb: 50
-
Restart DataStax Enterprise.
For package installs on Debian or Ubuntu:
sudo service dse restart
For tarball installs, see the topics on stopping and starting nodes.
-
Build and run Playlist using mvn.
-
In a web browser, navigate to
http://localhost:8080/playlist
.
Navigate through the artist or genre catalog several times. This will add the
table rows to the row cache.
-
In a separate terminal use the nodetool info command to see
the row cache entries and size.
nodetool info
Row Cache: entries 3, size 84.82 KB, capacity 50 MB, 4 hits, 7 requests, 0.571 recent hit rate, 0 save period in seconds
Each time you click on a genre or artist the cache size will increase.