pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Nichlas Löfdahl <crotalus@acc.umu.se>
Cc: pgsql-performance@postgresql.org
Subject: Re: Planner picks the wrong plan?
Date: Tue, 05 Oct 2004 23:29:56 -0400
Message-ID: <20687.1097033396@sss.pgh.pa.us> (raw)
In-Reply-To: <20041006004204.GA13074@shaka.acc.umu.se>
References: <20041006004204.GA13074@shaka.acc.umu.se>

Nichlas =?iso-8859-1?Q?L=F6fdahl?= <crotalus@acc.umu.se> writes:
> My question is, why doesn't the planner pick the same plan for Q1 & Q3?

I think it's mostly that after you've added and ANALYZEd the "age"
column, the planner has a pretty good idea of how many rows will pass
the "age > 17 AND age < 20" condition.  It can't do very much with the
equivalent condition in the original form, though, and in fact ends up
drastically underestimating the number of matching rows (86 vs reality
of 3021).  That leads directly to a bad plan choice :-(

			regards, tom lane



view thread (2+ messages)

Message-ID: <20687.1097033396@sss.pgh.pa.us>
Permalink:  ../20687.1097033396@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20687.1097033396@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, crotalus@acc.umu.se
  Subject: Re: Planner picks the wrong plan?
  In-Reply-To: <20687.1097033396@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