Skip site navigation (1) Skip section navigation (2)

Re: Query plan changing when queried data does not

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Harry Hehl" <Harry(dot)Hehl(at)diskstream(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Query plan changing when queried data does not
Date: 2006-12-18 17:07:58
Message-ID: 10440.1166461678@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-performance
"Harry Hehl" <Harry(dot)Hehl(at)diskstream(dot)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

In response to

pgsql-performance by date

Next:From: Jeff FrostDate: 2006-12-18 17:20:57
Subject: Re: opportunity to benchmark a quad core Xeon
Previous:From: Harry HehlDate: 2006-12-18 16:32:19
Subject: Query plan changing when queried data does not

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group