Not using index

From: Daniele Orlandi <daniele(at)orlandi(dot)com>
To: psql-hackers <hackers(at)postgreSQL(dot)org>
Subject: Not using index
Date: 2000-05-10 03:07:38
Message-ID: 3918D279.538EB935@orlandi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello,

I just installed PG 7.0 and did some testing. I found what I believe is
a strange behaviour:

xtnet=# \d telecom
Table "telecom"
Attribute | Type | Modifier
-----------+-------------+----------
regione | varchar(20) |
distretto | varchar(20) |
settore | varchar(20) |
descriz | varchar(60) |
cor_x | float8 |
cor_y | float8 |
cod_dis | varchar(4) |
rete_urb | varchar(24) |

xtnet=# create index telecom_regione on telecom ( regione );
CREATE

xtnet=# explain select distinct on (regione) * from telecom;
NOTICE: QUERY PLAN:

Unique (cost=0.00..4777.43 rows=3910 width=88)
-> Index Scan using telecom_regione on telecom (cost=0.00..4679.68
rows=39100 width=88)

EXPLAIN

xtnet=# explain select distinct on (regione) regione from telecom;
NOTICE: QUERY PLAN:

Unique (cost=4370.91..4468.66 rows=3910 width=12)
-> Sort (cost=4370.91..4370.91 rows=39100 width=12)
-> Seq Scan on telecom (cost=0.00..1079.00 rows=39100
width=12)

EXPLAIN

xtnet=# explain select distinct on (regione) distretto,regione from
telecom;
NOTICE: QUERY PLAN:

Unique (cost=4492.72..4590.47 rows=3910 width=24)
-> Sort (cost=4492.72..4492.72 rows=39100 width=24)
-> Seq Scan on telecom (cost=0.00..1079.00 rows=39100
width=24)

EXPLAIN

It seems like the index is used only if * appears in the target list.
???

Bye!

--
Daniele

-------------------------------------------------------------------------------
Daniele Orlandi - Utility Line Italia - http://www.orlandi.com
Via Mezzera 29/A - 20030 - Seveso (MI) - Italy
-------------------------------------------------------------------------------

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Travis Bauer 2000-05-10 03:21:15 Re: Problems compiling version 7
Previous Message Karl DeBisschop 2000-05-10 02:25:31 Re: 7.0 RPM?