From: | Marti Raudsepp <marti(at)juffo(dot)org> |
---|---|
To: | Kevin Grittner <kgrittn(at)ymail(dot)com> |
Cc: | Reece Hart <reece(at)harts(dot)net>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: automatically refresh all materialized views? |
Date: | 2014-03-11 19:42:41 |
Message-ID: | CABRT9RAJyxz0uW7w2P1GD-HE=O4yneAKqrzY8VENS9GGev8mQg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Mar 11, 2014 at 9:17 PM, Kevin Grittner <kgrittn(at)ymail(dot)com> wrote:
> I haven't been able to think of a way to create circular references
> among a set of materialized views, short of committing violence
> against the system catalog tables directly. What have I missed?
Not directly, but you can create circles with matviews selecting from
ordinary views:
create view v_a as select 1 i;
create materialized view m_a as select * from v_a;
create view v_b as select * from m_a;
create materialized view m_b as select * from v_b;
create or replace view v_a as select * from m_b; -- Cha-ching!
You probably won't hit them if you don't recurse into views in
pg_depends, but then you might miss some necessary dependencies.
I didn't really give this much thought though. Such a setup might not
be refresh'able after a restore because you run into a recursive
"materialized view "x" has not been populated". (Maybe it is possible
if the recursive reference occurs in a subquery that isn't scanned?
dunno)
Now that I tried it, pg_dump has this to say:
pg_dump: [sorter] WARNING: could not resolve dependency loop among these items:
pg_dump: [sorter] REFRESH MATERIALIZED VIEW m_a (ID 1971 OID 18834835)
pg_dump: [sorter] WARNING: could not resolve dependency loop among these items:
pg_dump: [sorter] REFRESH MATERIALIZED VIEW m_b (ID 1972 OID 18834843)
pg_dump: [sorter] WARNING: could not resolve dependency loop among these items:
pg_dump: [sorter] REFRESH MATERIALIZED VIEW m_a (ID 1971 OID 18834835)
pg_dump: [sorter] REFRESH MATERIALIZED VIEW m_b (ID 1972 OID 18834843)
Regards,
Marti
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Janes | 2014-03-11 19:47:12 | Re: Increase in max_connections |
Previous Message | Tom Lane | 2014-03-11 19:23:54 | Re: automatically refresh all materialized views? |