From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Vilson farias" <vilson(dot)farias(at)digitro(dot)com(dot)br> |
Cc: | pgsql-general(at)postgresql(dot)org, "SIMONE Carla MOSENA" <simone(dot)mosena(at)digitro(dot)com(dot)br> |
Subject: | Re: Sequencial scan over primary keys |
Date: | 2000-11-10 15:11:50 |
Message-ID: | 11282.973869110@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Vilson farias" <vilson(dot)farias(at)digitro(dot)com(dot)br> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-11-10 15:17:17 | Re: locales and indexes. |
Previous Message | Tom Lane | 2000-11-10 14:59:10 | Re: strange behvaviour in join? BUG in 7.02? |