Chapter 8

Indexing and Ordering Data Sets

WHAT’S IN THIS CHAPTER?

  • Creating indexes that help enhance query performance
  • Creating and maintaining indexes in document databases and column-family databases
  • Ordering NoSQL data sets
  • Making effective design choices to create optimal indexes and ordering patterns

You have already learned the essentials of querying NoSQL databases. In this chapter, you take the next step to ensure that your queries are fast and efficient. In relational databases, a common way to optimize query performance is to leverage database indexes. Similar concepts apply to the world of NoSQL as well.

Indexes exist to increase data access performance. In theory, they are similar in behavior to the index in a book. When you need to search for a term or a word in a book, you have two options, namely:

  • Scan the entire book page by page to search for the term or word.
  • Look up the index at the end to find the pages where the term or word can be found and then browse to those specific pages.

Between these two options it’s a no-brainer to look up the index as opposed to a page-by-page scan to find the term. It makes the job easy and saves time.

In an analogous manner you have two choices when accessing a record in a database:

  • Look through the entire collection or data set item by item.
  • Leverage the index to get to the relevant data quickly.

Obviously, again the index lookup is a preferred choice. Although the book index and database index are analogous, stretching ...

Get Professional NoSQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.