pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rosser Schwarz <rosser.schwarz@gmail.com>
To: Francisco Reyes <lists@natserv.com>
Cc: PostgreSQL performance <pgsql-performance@postgresql.org>
Subject: Re: Understanding explains
Date: Mon, 11 Oct 2004 17:03:07 -0500
Message-ID: <37d451f70410111503755fb751@mail.gmail.com> (raw)
In-Reply-To: <20041011164950.J97379@zoraida.natserv.net>
References: <20041011164950.J97379@zoraida.natserv.net>

while you weren't looking, Francisco Reyes wrote:

> Is there any disadvantage of having the enable_seqscan off?

Plenty.

The planner will choose whichever plan looks "cheapest", based on the
information it has available (table size, statistics, &c).  If a
sequential scan looks cheaper, and in your case above it clearly is,
the planner will choose that query plan.  Setting enable_seqscan =
false doesn't actually disable sequential scans; it merely makes them
seem radically more expensive to the planner, in hopes of biasing its
choice towards another query plan.  In your case, that margin made an
index scan look less expensive than sequential scan, but your query
runtimes clearly suggest otherwise.

In general, it's best to let the planner make the appropriate choice
without any artificial constraints.  I've seen pathalogical cases
where the planner makes the wrong choice(s), but upon analysis,
they're almost always attributable to poor statistics, long
un-vacuumed tables, &c.

/rls

-- 
:wq



view thread (3+ messages)  latest in thread

Message-ID: <37d451f70410111503755fb751@mail.gmail.com>
Permalink:  ../37d451f70410111503755fb751@mail.gmail.com/
Also on:    postgresql.org/message-id/37d451f70410111503755fb751@mail.gmail.com

 · 

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: rosser.schwarz@gmail.com, lists@natserv.com
  Subject: Re: Understanding explains
  In-Reply-To: <37d451f70410111503755fb751@mail.gmail.com>

* 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