9.3 beta and materialized views

Started by Thomas Kellereralmost 13 years ago4 messagesgeneral
Jump to latest
#1Thomas Kellerer
spam_eater@gmx.net

Hi,

I'm currently adding the support for materialized views to my SQL tool, and noticed that when creating a materialized view, a rewrite rule is also created that looks just like a rewrite rule for a "normal" view.

Using pg_get_ruledef() I see that the rule is defined like this:

REATE RULE "_RETURN" AS
ON SELECT TO matview_test DO INSTEAD
SELECT <here comes the select of the mview>

As the materialized view should be a "table" that can be selected from, I wonder what the purpose of the rewrite rule is?

Regards
Thomas

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Thomas Kellerer (#1)
Re: 9.3 beta and materialized views

Thomas Kellerer <spam_eater@gmx.net> writes:

I'm currently adding the support for materialized views to my SQL tool, and noticed that when creating a materialized view, a rewrite rule is also created that looks just like a rewrite rule for a "normal" view.

Yup.

As the materialized view should be a "table" that can be selected from, I wonder what the purpose of the rewrite rule is?

To store the matview's definition for use in REFRESH.

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Thomas Kellerer
spam_eater@gmx.net
In reply to: Tom Lane (#2)
Re: 9.3 beta and materialized views

Tom Lane wrote on 16.05.2013 19:36:

As the materialized view should be a "table" that can be selected from, I wonder what the purpose of the rewrite rule is?

To store the matview's definition for use in REFRESH.

Ah, right. Makes sense.

Thanks for the quick reply.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#4Kevin Grittner
Kevin.Grittner@wicourts.gov
In reply to: Thomas Kellerer (#3)
Re: 9.3 beta and materialized views

Thomas Kellerer <spam_eater@gmx.net> wrote:

Tom Lane wrote on 16.05.2013 19:36:

As the materialized view should be a "table" that can be
selected from, I wonder what the purpose of the rewrite rule
is?

To store the matview's definition for use in REFRESH.

Ah, right. Makes sense.

It will also be used to drive incremental update (in future
releases), as it does in every other product with materialized
views that I know of.  In 9.3 we only got as far as explicit
REFRESH, but I hope to improve on that in 9.4.

--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general