Sequencial scan over primary keys

From: "Vilson farias" <vilson(dot)farias(at)digitro(dot)com(dot)br>
To: <pgsql-general(at)postgresql(dot)org>
Cc: "SIMONE Carla MOSENA" <simone(dot)mosena(at)digitro(dot)com(dot)br>
Subject: Sequencial scan over primary keys
Date: 2000-11-10 12:16:47
Message-ID: 00b901c04b10$1ac5bb60$98a0a8c0@dti.digitro.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hello,

I need help in case below. My table tipo_categoria has a primary key,
called cod_categoria When I use this key as parameter for my sql script, the
result of execution is a sequencial scan, but this is a PRIMARY KEY, it does
has an index. How can it be explained?

sitest=# CREATE TABLE tipo_categoria (
sitest(# cod_categoria smallint NOT NULL,
sitest(# descricao varchar(40),
sitest(# CONSTRAINT XPKtipo_categoria PRIMARY KEY (cod_categoria)
sitest(#
sitest(# );
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index
'xpktipo_categoria' for table 'tipo_categoria'
CREATE
sitest=# copy tipo_categoria from '/home/postgres/categ.txt';
COPY
sitest=# explain select * from tipo_categoria where cod_categoria = 1;
NOTICE: QUERY PLAN:

Seq Scan on tipo_categoria (cost=0.00..22.50 rows=10 width=14)

EXPLAIN
sitest=# \di
List of relations
Name | Type | Owner
--------------------+-------+----------
...
xpktipo_categoria | index | postgres
...
(26 rows)
sitest=# select * from tipo_categoria;
cod_categoria | descricao
---------------+---------------------------------------
0 | Categoria chamador desconhecida
1 | Reserva
2 | Reserva
..
224 | Assinante com tarifacao especial
226 | Telefone publico interurbano
(20 rows)

Thanks.

José Vilson de Mello de Farias
Digitro Tecnologia Ltda - Brasil

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mathieu Arnold 2000-11-10 12:23:32 locales and indexes.
Previous Message Roger Wernersson 2000-11-10 10:55:40 Semaphores was: Increasing the number of semaphores on FreeBSD 4. 1 (clarification)