| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
| Cc: | Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>, Erik Wienhold <ewie(at)ewie(dot)name>, Said Assemlal <sassemlal(at)neurorx(dot)com>, pgsql-hackers(at)postgresql(dot)org, Haibo Yan <haibo(dot)yan(at)hotmail(dot)com> |
| Subject: | Re: CREATE OR REPLACE MATERIALIZED VIEW |
| Date: | 2026-08-14 18:05:18 |
| Message-ID: | 3774197.1786730718@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> I think CREATE OR REPLACE is the wrong syntax here. I think what
> people would most often want to do is edit the query used to refresh
> the query without disturbing the existing data, indexes, or other
> ancillary properties of the view in any way, but just changing what
> happens on next refresh. We have CREATE OR REPLACE FUNCTION because
> replacing a function in its entirety is a sensible thing to do, but we
> don't have CREATE OR REPLACE TABLE because tables contain data that
> you're unlikely to want to throw out. Materialized views are more like
> tables in this respect: they have data. Granted, it can be
> regenerated, but that's probably expensive.
> So I'd propose that this should be a form of ALTER MATERIALIZED VIEW,
> and that it be defined as suggested above, just replacing the refresh
> query.
This approach makes sense to me. Note that this would imply that the
revised query has to still produce the same set of columns, else it's
inconsistent with the MV's stored data (but maybe we could allow
adding new columns at the end, as with tables). I suppose this means
that if you want a different set of columns, you have no recourse
short of dropping the MV.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nathan Bossart | 2026-08-14 18:24:23 | Re: Doc update proposal for the note on log_statement in the runtime config for logging page |
| Previous Message | Robert Haas | 2026-08-14 17:34:45 | Re: CREATE OR REPLACE MATERIALIZED VIEW |