pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <david.rowley@2ndquadrant.com>
To: kdorsel@gmail.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #15869: Custom aggregation returns null when parallelized
Date: Mon, 24 Jun 2019 14:51:19 +1200
Message-ID: <CAKJS1f9ckNFoKDz7e5e_bLi-eyD2b+N04jLQSP+fGOte3J3t3g@mail.gmail.com> (raw)
In-Reply-To: <15869-32aa02312ddc6be7@postgresql.org>
References: <15869-32aa02312ddc6be7@postgresql.org>

On Mon, 24 Jun 2019 at 03:32, PG Bug reporting form
<noreply@postgresql.org> wrote:
> Here's the setup code:
> --CREATE TABLE temp (val double precision);
> --insert into temp (val) select i from generate_series(0, 150000) as t(i);
> --set force_parallel_mode = on;
> select (stats_agg(val)).* from temp;

I don't think force_parallel_mode does what you think it does. It just
adds a Gather node to the top of the plan, if the plan is deemed
parallel safe. It's not going to force your aggregate to be
parallelised.

You might coax the planner into generating a parallel aggregate plan
by setting parallel_tuple_cost and parallel_setup_cost both to 0.

> Expected results:
> 150001, 37500, 75000, 112500
>
> Results when run in parallel:
> 150001, null, null, null

Are you actually getting a partial and finalize aggregate node with
that? Can you show the EXPLAIN output of each?

You might also want to double check your combine function. It does not
look like it's very well coded to handle NULL values for arrays that
have yet to receive their fill of 5 elements.

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services





view thread (5+ messages)  latest in thread

Message-ID: <CAKJS1f9ckNFoKDz7e5e_bLi-eyD2b+N04jLQSP+fGOte3J3t3g@mail.gmail.com>
Permalink:  ../CAKJS1f9ckNFoKDz7e5e_bLi-eyD2b+N04jLQSP+fGOte3J3t3g@mail.gmail.com/
Also on:    postgresql.org/message-id/CAKJS1f9ckNFoKDz7e5e_bLi-eyD2b+N04jLQSP+fGOte3J3t3g@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: david.rowley@2ndquadrant.com
  Subject: Re: BUG #15869: Custom aggregation returns null when parallelized
  In-Reply-To: <CAKJS1f9ckNFoKDz7e5e_bLi-eyD2b+N04jLQSP+fGOte3J3t3g@mail.gmail.com>
  References: <15869-32aa02312ddc6be7@postgresql.org> <CAKJS1f9ckNFoKDz7e5e_bLi-eyD2b+N04jLQSP+fGOte3J3t3g@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox