O'Reilly logo

Rails, Angular, Postgres, and Bootstrap, 2nd Edition by David B. Copeland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required