select distinct, index not used

Поиск
Список
Период
Сортировка
От Thomas Guettler
Тема select distinct, index not used
Дата
Msg-id 49E7449D.5060301@tbz-pariv.de
обсуждение исходный текст
Ответы Re: select distinct, index not used
Re: select distinct, index not used
Список pgsql-general
Hi,

why does the statement take so long? The column 'lieferant' is indexed. But
a sequential scan gets done.


foo_egs_foo=# explain analyze SELECT DISTINCT "foo_abc_abc"."lieferant" FROM "foo_abc_abc";
                                                                QUERY PLAN


-------------------------------------------------------------------------------------------------------------------------------------------
 Unique  (cost=3361064.73..3438087.78 rows=7 width=8) (actual time=127133.435..127491.937 rows=34 loops=1)
   ->  Sort  (cost=3361064.73..3399576.26 rows=15404611 width=8) (actual time=127133.429..127322.101 rows=115830
loops=1)
         Sort Key: lieferant
         ->  Seq Scan on foo_abc_abc  (cost=0.00..468944.11 rows=15404611 width=8) (actual time=0.029..125458.870
rows=115830 loops=1)
 Total runtime: 127609.737 ms
(5 Zeilen)



foo_egs_foo=# \d foo_abc_abc
                                     Tabelle »public.foo_abc_abc«
         Spalte          |          Typ           |                          Attribute
-------------------------+------------------------+--------------------------------------------------------------
 id                      | integer                | not null default nextval('foo_abc_abc_id_seq'::regclass)
 ...
 lieferant               | character varying(32)  | not null

Indexe:
    »foo_abc_abc_pkey« PRIMARY KEY, btree (id)
    »foo_abc_abc_lieferant« btree (lieferant)
    ..


                                                     version
------------------------------------------------------------------------------------------------------------------
 PostgreSQL 8.2.4 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20061115 (prerelease) (SUSE Linux)
(1 Zeile)

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

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