Re: Timestamp indexes (why ">" or "between" does not use index?) - Mailing list pgsql-general

From Phoenix Kiula
Subject Re: Timestamp indexes (why ">" or "between" does not use index?)
Date
Msg-id e373d31e0802160813s78d7534ds71fa6336ba451339@mail.gmail.com
Whole thread Raw
In response to Re: Timestamp indexes (why ">" or "between" does not use index?)  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Timestamp indexes (why ">" or "between" does not use index?)
List pgsql-general
This table is vacuumed and analyzed every hour, so yes, it's been
analyzed recently.

These are the EXPLAIN ANALYZE outputs for both the equality condition
and the greater than condition:


orguser=# explain analyze select alias from clientswhere modify_date =
'2008-01-01' ;
                                                        QUERY PLAN

-----------------------------------------------------------------------------------------------------------------------------
 Index Scan using new_idx_modify_date on clients (cost=0.00..30.23
rows=8 width=10) (actual time=0.136..0.136 rows=0 loops=1)
  Index Cond: (modify_date = '2008-01-01 00:00:00'::timestamp without
time zone)
 Total runtime: 0.220 ms
(3 rows)

Time: 2.832 ms


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)

Time: 4539.850 ms



Welcome any thoughts. Thanks!

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Strict-typing benefits/costs
Next
From: Tom Lane
Date:
Subject: Re: SELECT CAST(123 AS char) -> 1