Re: Query Plan choice with timestamps

Поиск
Список
Период
Сортировка
От Giorgio Valoti
Тема Re: Query Plan choice with timestamps
Дата
Msg-id 15821866-9564-40E8-BC12-52ADD6D6EEA5@mac.com
обсуждение исходный текст
Ответ на Re: Query Plan choice with timestamps  (Richard Huxton <dev@archonet.com>)
Ответы Re: Query Plan choice with timestamps
Список pgsql-performance
On 07/ago/08, at 10:35, Richard Huxton wrote:

> Giorgio Valoti wrote:
>> Hi, I have a timestamptz field that I want to use with a query, but
>> I don’t need the full timestamp resolution, so I’ve created a
>> day_trunc(timestamptz) immutable function which I’ll use with the
>> query and with a new index:
>> logs=> create index test_idx on blackbox (day_trunc(ts));
>> However, the query plan doesn’t use the index:
>
> Does it use it ever? e.g. with
>  SELECT * FROM blackbox WHERE day_trunk(ts) = '...'

It’s used:

logs=> explain select * from blackbox where day_trunc(ts) =
day_trunc(now());
                                 QUERY PLAN
---------------------------------------------------------------------------
  Bitmap Heap Scan on blackbox  (cost=22.38..3998.43 rows=1239
width=264)
    Recheck Cond: (day_trunc(ts) = day_trunc(now()))
    ->  Bitmap Index Scan on date_idx  (cost=0.00..22.07 rows=1239
width=0)
          Index Cond: (day_trunc(ts) = day_trunc(now()))

--
Giorgio Valoti

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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: Plz Heeeelp! performance settings
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Query Plan choice with timestamps