Tom,

  I've tried like you said (::integer) but doesn't work. I tried another
way, using GROUP BY at the end, but no luck again. What now?

            Table "prog_teste"
    Attribute    |     Type     | Modifier
-----------------+--------------+----------
 cod_teste       | integer      | not null
...
Index: xpkprog_teste


Index "xpkprog_teste"
 Attribute |  Type
-----------+---------
 cod_teste | integer
unique btree (primary key)

sitest=# explain select * from prog_teste where cod_teste=90::integer;
NOTICE:  QUERY PLAN:

Seq Scan on prog_teste  (cost=0.00..1.21 rows=1 width=138)

EXPLAIN

sitest=# explain select * from prog_teste where cod_teste=90::integer order
by cod_teste;
NOTICE:  QUERY PLAN:

Sort  (cost=1.22..1.22 rows=1 width=138)
  ->  Seq Scan on prog_teste  (cost=0.00..1.21 rows=1 width=138)


Best regards,

José Vilson de Mello de Farias
Dígitro Tecnologia - Brasil











----- Original Message -----
From: Tom Lane <[EMAIL PROTECTED]>
To: Vilson farias <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>; SIMONE Carla MOSENA
<[EMAIL PROTECTED]>
Sent: Sexta-feira, 10 de Novembro de 2000 13:11
Subject: Re: [GENERAL] Sequencial scan over primary keys


: "Vilson farias" <[EMAIL PROTECTED]> writes:
: > 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(# );
:
: > 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)
:
: Try it with
:   select * from tipo_categoria where cod_categoria = 1::smallint;
:
: An unadorned literal "1" is an int, not a smallint, and the planner is
: not currently very smart about indexing cross-datatype comparisons.
:
: Alternatively, just declare your table with column type int.  Because of
: alignment requirements for the varchar column, you're not actually
: saving any space by using the smallint declaration anyway.
:
: regards, tom lane
:

Reply via email to