Re: Sequencial scan over primary keys
От | Tom Lane |
---|---|
Тема | Re: Sequencial scan over primary keys |
Дата | |
Msg-id | 11282.973869110@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Sequencial scan over primary keys ("Vilson farias" <vilson.farias@digitro.com.br>) |
Список | pgsql-general |
"Vilson farias" <vilson.farias@digitro.com.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
В списке pgsql-general по дате отправления: