Re: array UNNESTed to rows stable with respect to order?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Thiemo Kellner <thiemo(at)gelassene-pferde(dot)biz>
Cc: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: array UNNESTed to rows stable with respect to order?
Date: 2018-04-17 20:40:57
Message-ID: CAKFQuwYNER-h8qRN33+CLTfP0k8oYhTZhaTig=Gt3Oez2bHJWA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Apr 17, 2018 at 1:20 PM, Thiemo Kellner <thiemo(at)gelassene-pferde(dot)biz
> wrote:

> This works fine but I am not sure whether the ordering remains in the
> later use.

​It does not. If the array is not naturally ordered you will want to
attach a "with ordinality" clause to it for performing future ordering.

select * from unnest(ARRAY[3,6,4]::integer[]) with ordinality

Use LATERAL to move the unnest from the select-list section to the FROM
clause.

​David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Paul Jungwirth 2018-04-17 20:49:13 Re: array UNNESTed to rows stable with respect to order?
Previous Message Thiemo Kellner 2018-04-17 20:20:56 array UNNESTed to rows stable with respect to order?