Re: Indexes in PostgreSQL

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: jackfitz(at)yahoo(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Indexes in PostgreSQL
Date: 2005-04-18 23:08:31
Message-ID: 20050418230824.GA23125@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Apr 18, 2005 at 12:25:33PM -0700, jackfitz(at)yahoo(dot)com wrote:
> I was wondering if anyone could explain how to get the Query Analyzer
> to use an Index that is defined for the table instead of doing a table
> scan? I have a table with some indexes on it that seem NOT to get used
> when I think they should. :-) Not that I KNOW more than the Query
> Analyzer - but a Table Scan seems expensive - especially if an Index
> exists to help.
>
> Here is some of what I mean

<snip>

Your row estimates seem way off. Have you run ANALYZE recently?

> EXPLAIN ANALYZE select e.title,e."startDate",e."allDa­yFlag"
> from "Events" e where e."startDate" > '20050930' and e."endDate" <
> '20051101'
> /*
> "Seq Scan on "Events" e (cost=0.00..11706.64 rows=31739 width=34)
> (actual time=0.148..1171.191 rows=819 loops=1)"
> " Filter: (("startDate" > '2005-09-30 00:00:00'::timestamp without
> time zone) AND ("endDate" < '2005-11-01 00:00:00'::timestamp without
> time zone))"
> "Total runtime: 1173.067 ms"
> INDEX "dates_IX"
> ON "Events"
> USING btree
> ("startDate", "endDate");
> */

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kris Jurka 2005-04-19 00:33:00 Re: current transaction is aborted, commands ignored until
Previous Message Thomas Kellerer 2005-04-18 23:01:24 Re: current transaction is aborted, commands ignored