Re: Constraint exclusion-like behavior for UNION ALL views

From: Tony Cebzanov <tonycpsu(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Constraint exclusion-like behavior for UNION ALL views
Date: 2017-03-29 19:52:17
Message-ID: 6d028adb-e83a-2b0c-20d6-8fc972cc983c@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 3/29/17 3:39 PM, David G. Johnston wrote:

> That said, I'm not sure what using materialized views instead of normal
> tables buys you in the first place. I could see possibly using a
> materialized view as the current month's table but the historical tables
> usually don't require refreshing.

My example was simplified for brevity. The actual materialized views in
question do a significant amount of work, pulling from several other
tables, grouping/aggregating, etc. It would be possible to have that
same query populate a normal table instead of being stored as a
materialized view, but there's a reason materialized views were created
in the first place -- to avoid the overhead of manually creating
triggers and so forth -- and I was hoping to find a way to retain those
advantages while also being able to partition the views by date.

My thought was that since check constraints already exist for regular
tables, and since materialized views are implemented as tables (or
table-like substances) it seems reasonable that materialized views
should support check constraints and the query optimization that comes
with them.

-Tony

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Cherio 2017-03-29 20:34:19 Vacuuming tables with BRIN index and CLUSTER ON index
Previous Message David G. Johnston 2017-03-29 19:39:09 Re: Constraint exclusion-like behavior for UNION ALL views