7 Reading Data from ScyllaDB
This chapter covers
- Reading data from ScyllaDB
- Limiting, grouping, sorting, and paginating queries
- Understanding read performance
- Using ScyllaDB to denormalize your data via materialized views and indexes
When you store data in a database, you’re saving it there to read later. In the last chapter, you learned about saving data — and deleting it — from ScyllaDB. Accordingly, in this chapter, it’s time to learn about reads. You’ve done some basic SELECT
queries already, but here, you’ll learn more about the various clauses you can add to those queries to get exactly the data you’re looking for. You’ll also look into read performance so that you can understand your queries' behavior and avoid burdening your cluster with a deluge of slow queries. Lastly, you’ll learn about how ScyllaDB can aid you in denormalizing your data models, offering tradeoffs between query speed and data storage to reduce your maintenance efforts.
In preparation for this chapter, I’ve included a dataset containing some sample rows in the book’s code repo at https://github.com/scylladb-in-action/code.
In the ch07
folder is a file — 1-dataset.cql
. Copying its contents into your cqlsh
session inside one of the Scylla Docker containers will insert several rows to each of the tables, giving you rows to query against that you don’t have to type up and insert yourself. Once you’ve got that set up, it’s time to begin reading about reading.