Re: Why date index is not used

Поиск
Список
Период
Сортировка
От Tomas Vondra
Тема Re: Why date index is not used
Дата
Msg-id 44887875.8000502@fuzzy.cz
обсуждение исходный текст
Ответ на Why date index is not used  ("Andrus" <eetasoft@online.ee>)
Ответы Re: Why date index is not used  ("Dave Dutcher" <dave@tridecap.com>)
Список pgsql-performance
More precisely - the Postgres could use the index to speed up the
sorting, but in this case the sorting is very fast (less than one
second according to the output), so Postgres probably decided not
to use the index because it would be slower.

Btw. have you run ANALYZE on the table recently? What is the number
of distinct values in the 'kuupaev' column?

Tomas

> Why Postgres 8.1 does not use makse_kuupaev_idx index in the following query
> ?
>
> How to speed this query up ?
>
> explain analyze select * from makse order by kuupaev desc, kellaaeg desc
> limit 100
>
> "Limit  (cost=62907.94..62908.19 rows=100 width=876) (actual
> time=33699.551..33701.001 rows=100 loops=1)"
> "  ->  Sort  (cost=62907.94..63040.49 rows=53022 width=876) (actual
> time=33699.534..33700.129 rows=100 loops=1)"
> "        Sort Key: kuupaev, kellaaeg"
> "        ->  Seq Scan on makse  (cost=0.00..2717.22 rows=53022 width=876)
> (actual time=0.020..308.502 rows=53028 loops=1)"
> "Total runtime: 37857.177 ms"
>
>
> CREATE TABLE makse(
>   kuupaev date,
>   kellaaeg char(6) NOT NULL DEFAULT ''::bpchar,
>   guid char(36) NOT NULL,
>   CONSTRAINT makse_pkey PRIMARY KEY (guid) )
>
>
> CREATE INDEX makse_kuupaev_idx  ON makse  USING btree  (kuupaev);
>
>
> Andrus.


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

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: Why date index is not used
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Why date index is not used