Re: Combining Aggregates

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Kouhei Kaigai <kaigai(at)ak(dot)jp(dot)nec(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Amit Kapila <amit(dot)kapila(at)enterprisedb(dot)com>
Subject: Re: Combining Aggregates
Date: 2016-01-18 17:03:03
Message-ID: CAFj8pRCp6i2FhGDo1pazmGNmP8xTqo9CQTy319rycGbydNUXYw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> > # explain analyze select a%1000000,length(string_agg(b,',')) from ab
> group
> > by 1;
> > QUERY PLAN
> >
> ---------------------------------------------------------------------------------------------------------------------------
> > GroupAggregate (cost=119510.84..144510.84 rows=1000000 width=32)
> (actual
> > time=538.938..1015.278 rows=1000000 loops=1)
> > Group Key: ((a % 1000000))
> > -> Sort (cost=119510.84..122010.84 rows=1000000 width=32) (actual
> > time=538.917..594.194 rows=1000000 loops=1)
> > Sort Key: ((a % 1000000))
> > Sort Method: quicksort Memory: 102702kB
> > -> Seq Scan on ab (cost=0.00..19853.00 rows=1000000 width=32)
> > (actual time=0.016..138.964 rows=1000000 loops=1)
> > Planning time: 0.146 ms
> > Execution time: 1047.511 ms
> >
> >
> > Patched
> > # explain analyze select a%1000000,length(string_agg(b,',')) from ab
> group
> > by 1;
> > QUERY PLAN
> >
> ------------------------------------------------------------------------------------------------------------------------
> > HashAggregate (cost=24853.00..39853.00 rows=1000000 width=32) (actual
> > time=8072.346..144424.872 rows=1000000 loops=1)
> > Group Key: (a % 1000000)
> > -> Seq Scan on ab (cost=0.00..19853.00 rows=1000000 width=32)
> (actual
> > time=0.025..481.332 rows=1000000 loops=1)
> > Planning time: 0.164 ms
> > Execution time: 263288.332 ms
>
> Well, that's pretty odd. I guess the plan change must be a result of
> switching the transition type from internal to text, although I'm not
> immediately certain why that would make a difference.
>

It is strange, why hashaggregate is too slow?

Pavel

>
> --
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-01-18 17:09:07 Re: Combining Aggregates
Previous Message Tom Lane 2016-01-18 17:01:02 Re: Trivial fixes for some IDENTIFICATION comment lines