Re: Select on timestamp-day slower than timestamp alone

Поиск
Список
Период
Сортировка
От Reiner Dassing
Тема Re: Select on timestamp-day slower than timestamp alone
Дата
Msg-id 3EB7C000.9030206@wettzell.ifag.de
обсуждение исходный текст
Ответ на Select on timestamp-day slower than timestamp alone  (Reiner Dassing <dassing@wettzell.ifag.de>)
Список pgsql-performance
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?
>


В списке pgsql-performance по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Select on timestamp-day slower than timestamp alone
Следующее
От: Christopher Kings-Lynne
Дата:
Сообщение: Re: [HACKERS] Hypothetical suggestions for planner, indexing