From: | Thomas Guettler <hv(at)tbz-pariv(dot)de> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | select distinct, index not used |
Date: | 2009-04-16 14:45:49 |
Message-ID: | 49E7449D.5060301@tbz-pariv.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | David Fetter | 2009-04-16 15:21:38 | Re: [GENERAL] Performance of full outer join in 8.3 |
Previous Message | Adrian Klaver | 2009-04-16 14:06:54 | Re: a question about postgresql server connection |