pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Tom Lane <tgl@sss.pgh.pa.us>
To: Isaac Morland <isaac.morland@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Paul A Jungwirth <pj@illuminatedcomputing.com>
Cc: Erik Wienhold <ewie@ewie.name>
Cc: Said Assemlal <sassemlal@neurorx.com>
Cc: pgsql-hackers@postgresql.org, Haibo Yan <haibo.yan@hotmail.com>
Subject: Re: CREATE OR REPLACE MATERIALIZED VIEW
Date: Fri, 14 Aug 2026 15:01:19 -0400
Message-ID: <3778322.1786734079@sss.pgh.pa.us> (raw )
In-Reply-To: <CAMsGm5cSeROk+BhFUGY_eQuc9Mfy1Tg8nS=JeXYgS7V4xkmY-g@mail.gmail.com >
References: <e4382244-6b55-450b-a4f0-32959056ade4@ewie.name >
<e55c4930-f788-4bb0-a684-743621d6cfc5@neurorx.com >
<7afe68b0-f983-4a9f-a1b4-32188cebbf38@ewie.name >
<b74736cf-a4b4-4c32-8df1-d08abe9a14ed@ewie.name >
<d4bf3ccf-5c2b-448d-ad16-59dd6fbe2a2e@ewie.name >
<64495e31-0a91-4894-87f8-31451ee69f44@ewie.name >
<bf64dad9-eaaa-4911-b447-13acee89ea80@ewie.name >
<2724629.1743885428@sss.pgh.pa.us >
<5cd7ec92-ee61-4080-8fb6-0aed6a51eeaf@ewie.name >
<CA+renyW6-7aH74o-Gv2k+6emEXwznXxg=GkmTaKhDcresQQ9bg@mail.gmail.com >
<6d710ac3-3a66-4b31-b35a-0b4d9afdda42@ewie.name >
<CA+renyWJgjatyvJEKr9_GSnr3xr-sqLfhLR+rvw3MSygowR9xA@mail.gmail.com >
<CA+renyW8xM3wycsYCk7nDkx4ytTNLNntaGh5-4CXNi-ns8dCOw@mail.gmail.com >
<CA+TgmoZ3S8DhnnhR0EFSAnJ2O2NvWpriaAg-jx=9Lg2AUEpP=A@mail.gmail.com >
<3774197.1786730718@sss.pgh.pa.us >
<CAMsGm5cSeROk+BhFUGY_eQuc9Mfy1Tg8nS=JeXYgS7V4xkmY-g@mail.gmail.com >
Isaac Morland <isaac.morland@gmail.com> writes:
> This sounds like CREATE OR REPLACE to me, even if there is something to
> explain in the documentation about what happens to the existing data
> (assuming it is currently populated). I don't think of CREATE OR REPLACE as
> completely re-creating an object anyhow. Certainly it can't arbitrarily
> replace a function (can't change return type) nor a view (can't remove or
> change type of a column). It's OK if not all possible changes are supported
> by the "OR REPLACE" part of the command.
To my mind, the formal requirement for CREATE OR REPLACE should be
"if the command succeeds, the resulting object properties are
identical to what they'd be if we were creating it fresh" -- basically
a form of idempotency. It's okay to fail when there are reasons why
we can't or shouldn't make that so.
In particular, ISTM that if we invent CREATE OR REPLACE MATERIALIZED
VIEW, then the view content should be either computed afresh or left
empty (depending on WITH NO DATA); it should never leave stale data.
But I think Robert is correct that an ALTER command that does keep
the old data is often going to be what's wanted.
regards, tom lane
view thread (29+ messages) latest in thread
Message-ID: <3778322.1786734079@sss.pgh.pa.us>
Permalink: ../3778322.1786734079@sss.pgh.pa.us/
Also on: postgresql.org/message-id/3778322.1786734079@sss.pgh.pa.us
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, isaac.morland@gmail.com, robertmhaas@gmail.com, pj@illuminatedcomputing.com, ewie@ewie.name, sassemlal@neurorx.com, haibo.yan@hotmail.com
Subject: Re: CREATE OR REPLACE MATERIALIZED VIEW
In-Reply-To: <3778322.1786734079@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox