Re: Problem Designing Index

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Alan J Batsford" <AJBatsford(at)uss(dot)com>
Cc: "Bill Moran" <wmoran(at)potentialtech(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Problem Designing Index
Date: 2007-08-13 14:09:45
Message-ID: 87eji7seza.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Alan J Batsford" <AJBatsford(at)uss(dot)com> writes:

> Thanks for the help, after your email I went to capture some analyze output
> for you and when I did I figured to bump up the statistics on the two
> columns of interest from 100 to 1000. Now all statements return close to
> instantly.

Note that 1000 can take quite a lot of space in the statistics table. Make
sure it's vacuumed regularly and check that this isn't slowing down planning
of simple queries excessively.

Look at the explain analyze and check that the estimates are reasonably
accurate. They may have just flipped from being wildly inaccurate on the wrong
side of the decision point to wildly inaccurate but on the right side of the
decision point.

> Is this analyze tool something I need to run periodically to keep
> performance up? If so how often should I run it.

Yes. autovacuum likes to do it whenever 10% of the table has been updated, but
your mileage will vary considerably depending on how much your updates or
other DML affects the distribution which the queries are depending on.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Glaesemann 2007-08-13 14:13:51 Re: TimestampTZ
Previous Message Tom Lane 2007-08-13 14:09:15 Re: Unable to connect to PostgreSQL server via PHP