From: Reiner Dassing <dassing@wettzell.ifag.de>
To: Richard Huxton <dev@archonet.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Select on timestamp-day slower than timestamp alone
Date: Tue, 06 May 2003 16:00:32 +0200
Message-ID: <3EB7C000.9030206@wettzell.ifag.de> (raw)
References: <3EB75D5F.5080406@wettzell.ifag.de>
<200305061404.24194.dev@archonet.com>
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?
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: dassing@wettzell.ifag.de, dev@archonet.com
Subject: Re: Select on timestamp-day slower than timestamp alone
In-Reply-To: <3EB7C000.9030206@wettzell.ifag.de>
References: <3EB75D5F.5080406@wettzell.ifag.de> <200305061404.24194.dev@archonet.com> <3EB7C000.9030206@wettzell.ifag.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox