Re: Query plan changing when queried data does not

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Harry Hehl" <Harry.Hehl@xxxxxxxxxxxxxx> 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


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux