Re: Do Layered Views/Relations Preserve Sort Order ?

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Charles Sheridan <cesheri(at)swbell(dot)net>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Do Layered Views/Relations Preserve Sort Order ?
Date: 2015-09-11 15:30:48
Message-ID: CA+TgmoYC6GD8sWUKCY57gF8SZWjK--SWBQSwgCxUYKEbbCkt-w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 9, 2015 at 7:53 PM, Charles Sheridan <cesheri(at)swbell(dot)net> wrote:
> When there are several views defined on top of each other, are SELECTs on
> views that do not specify a SORT order guaranteed to preserve the cumulative
> sort order of the lower-level views ?
>
> Is the answer true for any arbitrarily large set of layered views?
>
> Is the answer the same if the layers of relations are a mix of views and
> tables ?

If a view definition includes an ORDER BY clause, the output of that
view will be sorted accordingly. But if you do something with that
output, like join it to another table, then the join might disturb the
sort order.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-09-11 15:35:16 Re: RLS open items are vague and unactionable
Previous Message Robert Haas 2015-09-11 15:29:21 Re: Latent cache flush hazard in RelationInitIndexAccessInfo