Re: Skip Orderby Execution for Materialized Views

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Zhang Mingli <zmlpostgres(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Skip Orderby Execution for Materialized Views
Date: 2023-10-01 16:05:49
Message-ID: CAKFQuwY8saejcBLptuTg=v2CFO0tNiRUJvFniC3R3Gc5GyzfYQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Oct 1, 2023 at 8:57 AM Zhang Mingli <zmlpostgres(at)gmail(dot)com> wrote:

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

We tend to do precisely what the user writes into their query. If they
don't want an order by they can remove it. I don't see any particular
reason we should be second-guessing them here. And what makes the trade-off
worse is the reasonable expectation that we'd provide a way to force an
ordering of the inserts should the user actually want it after we defaulted
to ignoring that part of their query.

But yes, you are correct that adding an order by to a materialized view is
typically pointless. To the extent it is detrimental varies since even
partially ordered results can save on processing time.

David J.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-10-01 17:24:01 Re: Fix receiving large legal tsvector from binary format
Previous Message Zhang Mingli 2023-10-01 15:02:17 Re: Skip Orderby Execution for Materialized Views