pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mark Kirkwood <markir@paradise.net.nz>
Cc: Tobias Brox <tobias@nordicbet.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Limit + group + join
Date: Sat, 27 Aug 2005 18:17:51 -0400
Message-ID: <10922.1125181071@sss.pgh.pa.us> (raw)
In-Reply-To: <430FD61A.3020902@paradise.net.nz>
References: <20050826002709.GK10328@tobias.lan>
	<430E85ED.60109@paradise.net.nz>
	<9501.1125071193@sss.pgh.pa.us>
	<430FD61A.3020902@paradise.net.nz>

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



view thread (17+ messages)  latest in thread

Message-ID: <10922.1125181071@sss.pgh.pa.us>
Permalink:  ../10922.1125181071@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/10922.1125181071@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, markir@paradise.net.nz, tobias@nordicbet.com
  Subject: Re: Limit + group + join
  In-Reply-To: <10922.1125181071@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox