Re: BUG #15882: Select .... UNION ALL

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "v(dot)campanella47(at)gmail(dot)com" <v(dot)campanella47(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #15882: Select .... UNION ALL
Date: 2019-07-02 09:22:19
Message-ID: CAKFQuwapAnKD3YFX91DxMnJF4qkYqYXwZ8y8fGP=-V9g8LYKPA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tuesday, July 2, 2019, PG Bug reporting form <noreply(at)postgresql(dot)org>
wrote:

> The following bug has been logged on the website:
>
> Bug reference: 15882
> Logged by: Vincenzo Campanella
> Email address: v(dot)campanella47(at)gmail(dot)com
> PostgreSQL version: 11.4
> Operating system: windows 10 build 1903
> Description:
>
> cSelect = "select 1 as prog,sum(imp_asl) as Importo_Asl,Count(Arc_Ref.n_
> Rif)
> as nRicette,sum(n_Pre) as nPrelievi " +
>
> "from " + MyFunc.cSchema + "Arc_Ref " +
>
> "where data >= '" + cAnno + "-01-01' and data <= '" + cAnno +
> "-01-31' and T_MPR='M' " +
>
> "union all " +
>
> "select 2 as prog,sum(imp_asl) as Importo_Asl,Count(Arc_Ref.n_Rif)
> as nRicette,sum(n_Pre) as nPrelievi " +
>
> "from " + MyFunc.cSchema + "Arc_Ref " +
>
> "where data >= '" + cAnno + "-02-01' and data <= '" + cAnno +
> "-02-" + MyFunc.Ultimo_Giorno_Mese(2, Converti.ToInt32(cAnno)) + "' and
> T_MPR='M' " +
> [...]

> This produces an unordered but random table.

unordered but random?

> I put the prog field and then make the ascending order on this field.
> In previous versions the order was in the typed sequence.
>

I too would expect the unioned rows to be produced in the order listed but
this is not bug because the only way PostgreSQL is required to maintain
record order in a query is if you specify an order by clause.

It occurs to me you are likely benefitting from the new parallel query
infrastructure here.

David J.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Manuel Rigger 2019-07-02 10:06:53 ALTER TABLE SET WITH OIDS fails after failed CONCURRENTLY index creation
Previous Message PG Bug reporting form 2019-07-02 08:28:18 BUG #15882: Select .... UNION ALL