Re: Query Rewrite for Materialized Views (Postgres Extension) - Mailing list pgsql-hackers

From Corey Huinker
Subject Re: Query Rewrite for Materialized Views (Postgres Extension)
Date
Msg-id CADkLM=fGj104pdza=GgenarkSmA+V+P1voeg82mxiT=ZmO+Kww@mail.gmail.com
Whole thread Raw
In response to Re: Query Rewrite for Materialized Views (Postgres Extension)  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: Query Rewrite for Materialized Views (Postgres Extension)
List pgsql-hackers
Hope it is useful or interesting for someone! Questions or comments are very welcome.

good idea.

Regards

Pavel

In a recent PgConf NYC presentation [1] I was talking about the technical hurdles to implementing materialized views that could be kept up to date at all times, and the benefits of having such a thing.

Some use cases can be addressed with eventually-consistent derivative table structures (Vertica's projections, PipelineDB's continuous views, etc), but those methods rely on the source data never having deletes or updates, or confining those updates to the "hot" part of the source tables, so it generally works for time-series data, but not for other cases.

It has occurred to me that Dave Fetter's work on ASSERTIONS [2] has common underpinnings with true continuous materialized views. In both cases, the creation of a system object causes the creations of insert/update/delete triggers on one or more existing tables. In the case of assertions, those triggers are run with the goal of raising an error if rows are returned from a query. In the case of a materialized view, those same triggers would be used to delete rows from a CMV and insert replacements rows. 

If we can get always-up-to-date materialized views, then Denty's work on query rewrite would have greatly enhanced utility.

 

pgsql-hackers by date:

Previous
From: Claudio Freire
Date:
Subject: Re: Making all nbtree entries unique by having heap TIDs participatein comparisons
Next
From: Robert Haas
Date:
Subject: Re: Removing "Included attributes in B-tree indexes" section from docs