Database Reference
In-Depth Information
Looking up rows by partition
The core reading experience of the MyStatus application will be an interface to read a giv-
en user's status updates. In order to do this, we need to be able to retrieve status updates for
a given user from the
user_status_updates
table. As you might expect, this follows
naturally from the CQL syntax we've seen in previous chapters:
SELECT * FROM "user_status_updates"
WHERE "username" = 'alice';
Previously, we've used the
WHERE
keyword to specify an exact value for a full primary
key. In the preceding query, we only specify the partition key part of the primary key,
which allows us to retrieve only those rows that we've asked for the partition:
In the results, we only see the rows whose
username
is
alice
. To emphasize what we
discussed in the previous chapter, in the
Looking up a specific status update
section, this is
a very efficient query. Cassandra stores all of
alice
's status updates together, already in
order; so returning this view of the table is quite inexpensive.