pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Harry Hehl <Harry.Hehl@diskstream.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Query plan changing when queried data does not
Date: Mon, 18 Dec 2006 12:07:58 -0500
Message-ID: <10440.1166461678@sss.pgh.pa.us> (raw)
In-Reply-To: <6AD4F3A63B017C4FB074E2C895AD1854E31A60@EXCHSRV.waterloonetworking.net>
References: <6AD4F3A63B017C4FB074E2C895AD1854E31A60@EXCHSRV.waterloonetworking.net>

"Harry Hehl" <Harry.Hehl@diskstream.com> writes:
> Why does vacuum full and reindex make a difference if the 3 tables are
> never updated or records deleted?

Probably because you did an ANALYZE somewhere and updated the planner's
stats.  I think your major problem is poor estimation of the ds_tables
result:

>                ->  Seq Scan on ds_tables  (cost=0.00..59.80 rows=1
> width=48) (actual time=15.208..15.968 rows=121 loops=1)
>                      Filter: ((lower(name) <> 'ds_omdatatest'::text) AND
> (lower(name) <> 'ds_ommessage'::text) AND (lower(name) <>
> 'ds_omusersetting'::text) AND (lower(name) <> 'ds_omloginsession'::text)
> AND (lower(name) <> 'ds_omclassdef'::text) AND (lower(name) <>
> 'ds_omuser'::text) AND (lower(name) <> 'ds_omusergroupsetting'::text)
> AND (lower(name) <> 'ds_omtestobject'::text) AND (lower(name) <>
> 'ds_omhomedirectory'::text) AND (lower(name) ~~ 'ds_om%'::text))

If you have an index on lower(name) then ANALYZE will collect statistics
on it, and you'd get an estimate of the result size that was better than
random chance ... but I bet you have no such index.  You might get some
improvement from raising the default statistics target, too.

			regards, tom lane



view thread (2+ messages)

Message-ID: <10440.1166461678@sss.pgh.pa.us>
Permalink:  ../10440.1166461678@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/10440.1166461678@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, Harry.Hehl@diskstream.com
  Subject: Re: Query plan changing when queried data does not
  In-Reply-To: <10440.1166461678@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