Materialized views

One of the most effective ways to speed up queries against large datasets that are run more than once is to cache the result in a materialized view—essentially a view that is run and its output stored for future reference. Work on adding these into the core database is in progress but, like counting, it's possible to build them right now using features such as triggers. See http://wiki.postgresql.org/wiki/Materialized_Views for comments on the state-of-the-art stuff here, and pointers to code samples. If you have views derived from large tables in the database, few techniques are as effective as materializing those views and optimizing their updates for improving query performance.

Get PostgreSQL 10 High Performance 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.