HAVING push-down - Mailing list pgsql-hackers

From Simon Riggs
Subject HAVING push-down
Date
Msg-id 1169819613.3772.329.camel@silverbirch.site
Whole thread Raw
Responses Re: HAVING push-down  (Gregory Stark <stark@enterprisedb.com>)
Re: HAVING push-down  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I've just read a paper that says PostgreSQL doesn't do this. My reading
of the code is that we *do*  evaluate the HAVING clause prior to
calculating the aggregates for it. I thought I'd check to resolve the
confusion.

- - -

If not, it seems fairly straightforward to push down some or all of a
HAVING clause so that the qual clause is tested prior to aggregation,
not after aggregation. This could, for certain queries, significantly
reduce the amount of effort that the final Agg node performs.

We might think about deeper push-down within the query, but since the
Agg node already has the havingQual, it seems a straightforward act to
decide whether to apply it before or after the aggregation.

We already do find_unaggregated_cols(), so little additional analysis
seems required.

--  Simon Riggs              EnterpriseDB   http://www.enterprisedb.com




pgsql-hackers by date:

Previous
From: Jan Wieck
Date:
Subject: Re: Proposal: Commit timestamp
Next
From: "Greg Sabino Mullane"
Date:
Subject: Re: [pgsql-patches] pg_dump pretty_print