Re: Query plan changing when queried data does not - Mailing list pgsql-performance

From Tom Lane
Subject Re: Query plan changing when queried data does not
Date
Msg-id 10440.1166461678@sss.pgh.pa.us
Whole thread Raw
In response to Query plan changing when queried data does not  ("Harry Hehl" <Harry.Hehl@diskstream.com>)
List pgsql-performance
"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

pgsql-performance by date:

Previous
From: "Harry Hehl"
Date:
Subject: Query plan changing when queried data does not
Next
From: Jeff Frost
Date:
Subject: Re: opportunity to benchmark a quad core Xeon