From: | Josh Berkus <josh(at)agliodbs(dot)com> |
---|---|
To: | Jeremiah Jahn <jeremiah(at)cs(dot)earlham(dot)edu>, postgres performance <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: cross table indexes or something? |
Date: | 2003-12-02 19:27:52 |
Message-ID: | 200312021127.52839.josh@agliodbs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Jeremiah,
> Thanks to all, I had already run analyze. But the STATISTICS setting
> seems to have worked. I'm just not sure what it did..? Would anyone care
> to explain.
The STATISTICS setting improves the granularity of statistics kept by the
query planner on that column; increasing the granularity (i.e. more random
samples) can significantly improve things in cases where you have data whose
distribution is significantly skewed. Certainly whenever you see the query
planner using a slow nestloop becuase of a bad row-return estimate, it is one
of the first things to try.
Its drawbacks are 4-fold:
1) to keep it working, you will probably need to run ANALZYE more often than
you have been;
2) these ANALYZEs will take longer, and have the annoying side effect of
flooring your CPU while they do;
3) You will have to be sure that your vacuum plan includes vacuuming the
pg_statistic table as the database superuser, as that table will be getting
updated more often.
4) Currently, pg_dump does *not* back up statistics settings. So you will
need to save a script which does this in preparation for having to restore
your database.
Which is why the stats are set low by default.
--
Josh Berkus
Aglio Database Solutions
San Francisco
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Stark | 2003-12-02 20:11:02 | Re: A question on the query planner |
Previous Message | Jared Carr | 2003-12-02 19:14:19 | Re: A question on the query planner |