pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #15851: Concurrent Refresh of Materialized views not preserving the order of the underlying query
5+ messages / 5 participants
[nested] [flat]
* BUG #15851: Concurrent Refresh of Materialized views not preserving the order of the underlying query
@ 2019-06-13 19:35 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 5+ messages in thread
From: PG Bug reporting form @ 2019-06-13 19:35 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: sai.dulla@berkeley.edu
The following bug has been logged on the website:
Bug reference: 15851
Logged by: Sai D
Email address: sai.dulla@berkeley.edu
PostgreSQL version: 10.5
Operating system: Ubuntu 16.04.10
Description:
Tests Run:
Materialized view refresh concurrently with unique index:
Sort order is not the same as that of the output of the underlying query
Tested with Unique Index key that is the same as the sort order columns in
the underlying query.
Results: Incorrect sort order after refresh concurrently
Tested with Unique Index key that is different from the sort order columns
in the underlying query.
Results: Incorrect sort order after refresh concurrently
Materialized view refresh with unique index (Plain refresh, no concurrently
key word in the refresh command):
Sort order is the same as that of the output of the underlying query
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #15851: Concurrent Refresh of Materialized views not preserving the order of the underlying query
@ 2019-06-14 00:28 Tom Lane <tgl@sss.pgh.pa.us>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 3 replies; 5+ messages in thread
From: Tom Lane @ 2019-06-14 00:28 UTC (permalink / raw)
To: sai.dulla@berkeley.edu; +Cc: pgsql-bugs@lists.postgresql.org
PG Bug reporting form <noreply@postgresql.org> writes:
> Materialized view refresh concurrently with unique index:
> Sort order is not the same as that of the output of the underlying query
I do not think this is a bug. A matview is basically a table, and
tables don't guarantee to preserve row ordering.
Possibly we need to clarify the docs around this point.
A more aggressive approach would be to reject ORDER BY in the
query defining a matview, but perhaps that's too in-your-face...
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* BUG #15851: Concurrent Refresh of Materialized views not preserving the order of the underlying query
@ 2019-06-14 00:47 David G. Johnston <david.g.johnston@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
2 siblings, 0 replies; 5+ messages in thread
From: David G. Johnston @ 2019-06-14 00:47 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: sai.dulla@berkeley.edu <sai.dulla@berkeley.edu>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
On Thursday, June 13, 2019, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> PG Bug reporting form <noreply@postgresql.org> writes:
> > Materialized view refresh concurrently with unique index:
> > Sort order is not the same as that of the output of the underlying query
>
> I do not think this is a bug. A matview is basically a table, and
> tables don't guarantee to preserve row ordering.
>
> Possibly we need to clarify the docs around this point.
>
> A more aggressive approach would be to reject ORDER BY in the
> query defining a matview, but perhaps that's too in-your-face...
>
>
The notes section for refresh already mentions cluster and adding an
explicit order by; and they both seem like good points when working with
non-concurrent semantics. Probably should just add another sentence or two:
When operating in CONCURRENTLY mode the deltas that are calculated are
applied as a sequence of normal insert/update/delete. A subsequent CLUSTER
would need to be run on the materialized view if one wishes for the entire
table to be physically ordered again (though consider a lower fill-factor
for the materialized view to reduce the amount of work such a cluster would
need to accomplish).
David J.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #15851: Concurrent Refresh of Materialized views not preserving the order of the underlying query
@ 2019-06-14 01:17 David Rowley <david.rowley@2ndquadrant.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
2 siblings, 0 replies; 5+ messages in thread
From: David Rowley @ 2019-06-14 01:17 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: sai.dulla@berkeley.edu, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
On Fri, 14 Jun 2019 at 12:29, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> A more aggressive approach would be to reject ORDER BY in the
> query defining a matview, but perhaps that's too in-your-face...
Yeah. I think if we'd thought about it at the time we'd probably have
rejected an ORDER BY in the view definition. Doing that today might
break pg_upgrade and pg_restore. Do you think there's any merit in a
WARNING during CREATE MATERIALIZED VIEW if the query has an ORDER BY?
--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #15851: Concurrent Refresh of Materialized views not preserving the order of the underlying query
@ 2019-06-17 16:48 Andres Freund <andres@anarazel.de>
parent: Tom Lane <tgl@sss.pgh.pa.us>
2 siblings, 0 replies; 5+ messages in thread
From: Andres Freund @ 2019-06-17 16:48 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: sai.dulla@berkeley.edu; pgsql-bugs@lists.postgresql.org
Hi,
On 2019-06-13 20:28:54 -0400, Tom Lane wrote:
> A more aggressive approach would be to reject ORDER BY in the
> query defining a matview, but perhaps that's too in-your-face...
That'd probably be over the top - ISTM it can make plenty of sense to
"pre order" a matview, especially if you're going to create several
indexes.
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2019-06-17 16:48 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-06-13 19:35 BUG #15851: Concurrent Refresh of Materialized views not preserving the order of the underlying query PG Bug reporting form <noreply@postgresql.org>
2019-06-14 00:28 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-06-14 00:47 ` David G. Johnston <david.g.johnston@gmail.com>
2019-06-14 01:17 ` David Rowley <david.rowley@2ndquadrant.com>
2019-06-17 16:48 ` Andres Freund <andres@anarazel.de>
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