Indexes and querys

Started by Josué Maldonadoover 22 years ago2 messagesgeneral
Jump to latest
#1Josué Maldonado
josue@lamundial.hn

Hello list,

I have a table with an index in a foreing key field (int4), if I do
select from pedido where prvdfk=3, explain says is using seq scan to
access it. I noticed all my querys runs in that way, except in the
querys where the PK field (unique type index) is included in the where
clause.

Is this the rigth way that postgresql works ?, is there something I
should check in my configuration?

According to select version() this is the my one:
PostgreSQL 7.3.4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2
20020903 (Red Hat Linux 8.0 3.2-7)

Thanks in advance

--
Josu� Maldonado.

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Josué Maldonado (#1)
Re: Indexes and querys

Josuᅵ Maldonado writes:

I have a table with an index in a foreing key field (int4), if I do
select from pedido where prvdfk=3, explain says is using seq scan to
access it. I noticed all my querys runs in that way, except in the
querys where the PK field (unique type index) is included in the where
clause.

PostgreSQL will choose to use an index when it thinks it will be faster,
but this is not always the case. If you want to learn more about how
indexes work or how to evaluate query performance, please read the
documentation.

--
Peter Eisentraut peter_e@gmx.net