Re: order by not working in view ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Gauthier <davegauthierpg(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: order by not working in view ?
Date: 2020-04-09 14:41:37
Message-ID: 5555.1586443297@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

David Gauthier <davegauthierpg(at)gmail(dot)com> writes:
> In the copy/paste below, first 2 lines returned by a select on the view,
> why didn't it sort on start_datetime correctly ?

Putting an ORDER BY in a view is a bit dangerous (last I looked,
it wasn't even legal in standard SQL). Yeah, the view will sort,
but there is nothing compelling the calling query to preserve
the ordering.

EXPLAIN would give you more info, but I'm betting that the IN is being
converted to a semijoin and then done with a non-order-preserving join
method.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2020-04-09 14:57:14 Re: order by not working in view ?
Previous Message Stephen Frost 2020-04-09 14:41:22 Re: full text