Chapter 10Cache Complex Queries Using Materialized Views
When you need to query data stored in several tables, there is a trade-off. Either you keep the code simple by using Active Record—which makes several queries to the database—or you make the code more complex by using a single, efficient query specific to your needs. Performance is an issue in both cases because you’re pulling back a lot of data. Postgres solves this dilemma with its materialized views feature, which provides clean code, accesses data with a single query, and exhibits high performance.
In this chapter, we’ll continue to build on our running example where we display a customer’s details. To do this, we need to fetch data from five different tables. You’ll see how the ...
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.