Hello Richard!
Your proposal to use an explicit cast to "with time zone" helps:
explain
select * from wetter where epoche between
'2003-05-06 06:50:54+00'::timestamp with time zone-'1 days'::interval
AND '2003-05-06 04:45:36';
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------
Index Scan using wetter_epoche_idx on wetter (cost=0.00..5.45 rows=1
width=16)
Index Cond: ((epoche >= '2003-05-05 06:50:54+00'::timestamp with
time zone) AND (epoche <= '2003-05-06 04:45:36+00'::timestamp with time
zone))
(2 rows)
The result now is like expected.
Thanks for the help.
But for your question "why we get "timestamp without time zone"."
I have no answer.
Reiner
>
>>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?
>