Re: Timestamp indexes (why ">" or "between" does not use index?)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Phoenix Kiula" <phoenix(dot)kiula(at)gmail(dot)com>
Cc: "Michael Glaesemann" <grzm(at)seespotcode(dot)net>, "PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Timestamp indexes (why ">" or "between" does not use index?)
Date: 2008-02-16 16:29:17
Message-ID: 20311.1203179357@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Phoenix Kiula" <phoenix(dot)kiula(at)gmail(dot)com> writes:
> orguser=# explain analyze select alias from clientswhere modify_date >
> '2008-01-01' ;
> QUERY PLAN
> ------------------------------------------------------------------------------------------------------------------
> Seq Scan on clients (cost=0.00..237043.09 rows=136617 width=10)
> (actual time=0.391..4007.188 rows=148225 loops=1)
> Filter: (modify_date > '2008-01-01 00:00:00'::timestamp without time zone)
> Total runtime: 4539.242 ms
> (3 rows)

Given the large number of rows being retrieved, I'm not sure that the
seqscan choice is wrong. You could force the issue by setting
enable_seqscan = off; see what EXPLAIN ANALYZE gives you then.

If it does come out significantly faster, this may mean that you need
to dial down random_page_cost to make the planner's cost estimates
for indexscans be closer to reality on your machine. Be wary however
of changing that parameter on the basis of only one test case.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message jerry.evans@chordia 2008-02-16 16:30:30 Analogue to SQL Server UniqueIdentifier?
Previous Message Ken Johanson 2008-02-16 16:18:47 Re: Strict-typing benefits/costs