pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Gary Doades <gpd@gpdnet.co.uk>
Cc: pgsql-performance@postgresql.org
Subject: Re: Odd planner choice?
Date: Fri, 08 Oct 2004 16:04:42 -0400
Message-ID: <15493.1097265882@sss.pgh.pa.us> (raw)
In-Reply-To: <4166F956.21282.29EC515A@localhost>
References: <4166F956.21282.29EC515A@localhost>

"Gary Doades" <gpd@gpdnet.co.uk> writes:
> If I remove the redundant clauses, the planner now estimates 1000 rows returned from 
> the table, not unreasonable since it has no statistics. But *why* in that case, with *more* 
> estimated rows does it choose to materialize that table (26 rows) 573416 times!!!

It isn't.  It's materializing that once and scanning it 573416 times,
once for each row in the outer relation.  And this is not a bad plan
given the estimates.  If it had stuck to what you call the good plan,
and there *had* been 1000 rows in the temp table, that plan would have
run 1000 times longer than it did.

As a general rule, if your complaint is that you get a bad plan for an
unanalyzed table, the response is going to be "so analyze the table".

			regards, tom lane



view thread (7+ messages)  latest in thread

Message-ID: <15493.1097265882@sss.pgh.pa.us>
Permalink:  ../15493.1097265882@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/15493.1097265882@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, gpd@gpdnet.co.uk
  Subject: Re: Odd planner choice?
  In-Reply-To: <15493.1097265882@sss.pgh.pa.us>
  References: <4166F956.21282.29EC515A@localhost> <15493.1097265882@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