Re: cross table indexes or something? - Mailing list pgsql-performance

From Josh Berkus
Subject Re: cross table indexes or something?
Date
Msg-id 200312021127.52839.josh@agliodbs.com
Whole thread Raw
In response to Re: cross table indexes or something?  (Jeremiah Jahn <jeremiah@cs.earlham.edu>)
Responses Re: cross table indexes or something?
Re: cross table indexes or something?
List 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

pgsql-performance by date:

Previous
From: Jared Carr
Date:
Subject: Re: A question on the query planner
Next
From: Greg Stark
Date:
Subject: Re: A question on the query planner