Skip site navigation (1) Skip section navigation (2)

Re: sum(int4)/sum(int2) improvement

From: Atsushi Ogawa <a_ogawa(at)hi-ho(dot)ne(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: sum(int4)/sum(int2) improvement
Date: 2005-09-02 12:09:55
Message-ID: PIEMIKOOMKNIJLLLBCBBAEPKCKAA.a_ogawa@hi-ho.ne.jp (view raw or flat)
Thread:
Lists: pgsql-patches
Tom Lane wrote:
> I went back and looked at your AllocSetReset patch from last May, and
> liked it better on second consideration.

> I'll fix up the old patch and apply it.  I think that's a better answer
> than kluging up the aggregate functions themselves.

Thanks. I also think this fix is better. It speeds up hash join etc. besides
sum(int4) and sum(int2).

Example:
- SQL
select b.bid, count(*)
from accounts a, branches b
where a.bid = b.bid
group by b.bid;

- Query Plan
HashAggregate  (cost=23198.06..23198.08 rows=5 width=4)
  ->  Hash Join  (cost=1.06..20698.06 rows=500000 width=4)
        Hash Cond: ("outer".bid = "inner".bid)
        ->  Seq Scan on accounts a  (cost=0.00..13197.00 rows=500000
width=4)
        ->  Hash  (cost=1.05..1.05 rows=5 width=4)
              ->  Seq Scan on branches b  (cost=0.00..1.05 rows=5 width=4)

- Result
 original: 2.416s
 patched:  2.286s

regards,

--- Atsushi Ogawa


In response to

pgsql-patches by date

Next:From: Matt MillerDate: 2005-09-02 14:34:50
Subject: Re: PL/pgSQL: EXCEPTION NOSAVEPOINT
Previous:From: Koichi SuzukiDate: 2005-09-02 10:36:42
Subject: Re: A couple of patches for PostgreSQL 64bit support

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group