From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Reiner Dassing <dassing(at)wettzell(dot)ifag(dot)de>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Select on timestamp-day slower than timestamp alone |
Date: | 2003-05-06 13:04:24 |
Message-ID: | 200305061404.24194.dev@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Tuesday 06 May 2003 7:59 am, Reiner Dassing wrote:
> Hello all!
>
> On PostgreSQL V7.3.2 on TRU64 I recognized the following phenomena
> that a SELECT using a difference of a timestamp and an interval
> in the WHERE clause does not use the index
> but using a timestamp without a difference does use the index.
> The semantic of both SELECT's is equal, i.e., the result is equal.
>
> Therefore, the second way is much faster.
>
> Any ideas?
> Select not using index:
> -----------------------
> wetter=# explain select * from wetter where epoche between
> '2003-05-06 06:50:54+00'::timestamp-'1 days'::interval
> AND '2003-05-06 04:45:36';
>
> QUERY PLAN
>
> ---------------------------------------------------------------------------
>----------------------------------------------------------------------------
>-------------------- Seq Scan on wetter (cost=0.00..768644.57 rows=10253528
> width=16) Filter: ((epoche >= ('2003-05-05 06:50:54'::timestamp without
> time zone)::timestamp with time zone) AND (epoche <= '2003-05-06
> 04:45:36+00'::timestamp with time zone))
> (2 rows)
Well, the "why" is because the number of rows recommended is so big
(rows=10253528) - I'm also puzzled why we get "timestamp without time zone".
Does an explicit cast to "with time zone" help?
--
Richard Huxton
From | Date | Subject | |
---|---|---|---|
Next Message | Jim C. Nasby | 2003-05-06 13:07:47 | Re: [HACKERS] Hypothetical suggestions for planner, indexing improvement |
Previous Message | Fabio C. Bon | 2003-05-06 12:21:16 | A query with performance problems. |