Re: Why does adding SUM and GROUP BY destroy performance?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ang Chin Han <angch(at)bytecraft(dot)com(dot)my>
Cc: Christopher Browne <cbbrowne(at)acm(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: Why does adding SUM and GROUP BY destroy performance?
Date: 2003-09-19 14:50:15
Message-ID: 18770.1063983015@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ang Chin Han <angch(at)bytecraft(dot)com(dot)my> writes:
> Christopher Browne wrote:
>> When you use SUM (or other aggregates), there are no short cuts to
>> walking through each and every tuple specified by the WHERE clause.

> Er... not in this case, if I read David's email correctly.

> His first query is walking through every tuple anyway.

No, it isn't, because he had a LIMIT. I think the real point is that
computing the first fifty groups requires sucking in a lot more tuples
than just computing the first fifty rows.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-09-19 15:04:05 Re: Column defaults fail with rules on view
Previous Message Robert Treat 2003-09-19 14:20:45 Re: DDL diff utility?