Re: Explain Analyze help

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Mark Lubratt <mark(dot)lubratt(at)indeq(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: Explain Analyze help
Date: 2004-03-11 09:02:31
Message-ID: 200403111002.31577.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Mark Lubratt wrote:
> Obivously, I have a lot of sequential scans going on, at about what
> cost does it start to make sense to make an index? Or, should I just
> put in a bunch of indexes and let the optimizer decide whether or not
> to use them?

Read the chapters on Indexes and Performance Tips in the documentation.
They contain various example scenarios where indexes are useful. Keep
in mind that indexes are useful only if your table is large (say, 10000
rows or more) and the fraction you select is small (say, 1%). The
costs that EXPLAIN prints out are not meaningful absolute values; they
are only useful to compare two plans of the same query. So in absence
of a better approach, your job is to

1. EXPLAIN ANALYZE without index
2. create index
3. EXPLAIN ANALYZE with index

(And don't forget to run ANALYZE sometime.)

If there is a significant improvement, then keep the index. Remember,
too many indexes slow down updates.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Pablo Marrero 2004-03-11 13:54:03 started Data Warehousing
Previous Message Tom Lane 2004-03-11 04:09:41 Re: [PERFORM] syslog slowing the database?