pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Jeremiah Jahn <jeremiah@cs.earlham.edu>
To: postgres performance <pgsql-performance@postgresql.org>
Subject: Re: cross table indexes or something?
Date: Tue, 2 Dec 2003 11:27:52 -0800
Message-ID: <200312021127.52839.josh@agliodbs.com> (raw)
In-Reply-To: <1070392092.22346.43.camel@bluejay.goodinassociates.com>
References: <1069877651.22346.13.camel@bluejay.goodinassociates.com>
	<200312011147.51359.josh@agliodbs.com>
	<1070392092.22346.43.camel@bluejay.goodinassociates.com>

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



view thread (14+ messages)  latest in thread

Message-ID: <200312021127.52839.josh@agliodbs.com>
Permalink:  ../200312021127.52839.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200312021127.52839.josh@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: josh@agliodbs.com, jeremiah@cs.earlham.edu
  Subject: Re: cross table indexes or something?
  In-Reply-To: <200312021127.52839.josh@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox