Re: Limit + group + join - Mailing list pgsql-performance

From Tom Lane
Subject Re: Limit + group + join
Date
Msg-id 10922.1125181071@sss.pgh.pa.us
Whole thread Raw
In response to Re: Limit + group + join  (Mark Kirkwood <markir@paradise.net.nz>)
Responses Re: Limit + group + join
List pgsql-performance
Mark Kirkwood <markir@paradise.net.nz> writes:
> joinlimit=# EXPLAIN SELECT c.id FROM c JOIN b ON c_id=c.id  GROUP BY
> c.id ORDER BY c.id DESC LIMIT 5;
> [ fails to pick an available index-scan-backward plan ]

I looked into this and found that indeed the desirable join plan was
getting generated, but it wasn't picked because query_planner didn't
have an accurate idea of how much of the join needed to be scanned to
satisfy the GROUP BY step.  I've committed some changes that hopefully
will let 8.1 be smarter about GROUP BY ... LIMIT queries.

            regards, tom lane

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: Weird performance drop after VACUUM
Next
From: Mark Kirkwood
Date:
Subject: Re: Limit + group + join