Re: Skip Orderby Execution for Materialized Views - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Skip Orderby Execution for Materialized Views
Date
Msg-id 1719350.1696172086@sss.pgh.pa.us
Whole thread Raw
In response to Skip Orderby Execution for Materialized Views  (Zhang Mingli <zmlpostgres@gmail.com>)
Responses Re: Skip Orderby Execution for Materialized Views
List pgsql-hackers
Zhang Mingli <zmlpostgres@gmail.com> writes:
> When create  or refresh a Materialized View, if the view’s query has order by, we may sort and insert the sorted data
intoview. 

Indeed.

> And if it’s true, shall we skip the order by clause for Materialized View  when executing create/refresh statement?

No.  The intent of a materialized view is to execute the query
as presented.  If the user doesn't understand the consequences
of that, it's not our job to think we are smarter than they are.

I think this patch should be rejected.

BTW, I'm pretty certain that this patch breaks some valid cases
even if we take your point of view as correct.  For one example,
you can't just remove the sort clause if the query uses DISTINCT ON.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Zhang Mingli
Date:
Subject: Skip Orderby Execution for Materialized Views
Next
From: Andrew Dunstan
Date:
Subject: Re: Regression in COPY FROM caused by 9f8377f7a2