Understanding Query Performance with the Query Plan

If you aren’t familiar with database indexes, Wikipedia has a pretty good definition,[35] but in essence, an index is a data structure created inside the database that speeds up query operations. Usually, databases use advanced data structures like B-trees to find the data you’re looking for without examining every single row in a table.

If you are familiar with indexes, you might only be familiar with the type of indexes that can be created by Active Record’s Migrations API. This API provides a “lowest common denominator” approach. The best we can do is create an index on last_name, first_name, and email. Doing so won’t actually help us because of the search we are doing. We need to match ...

Get Rails, Angular, Postgres, and Bootstrap, 2nd Edition 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.