On Jun 12, 2007, at 8:32 , Christo Du Preez wrote:
I have noticed that my server never uses indexing. No matter what I
do.
As an example I took a table with about 650 rows, having a parentid
field with an index on parentid.
EXPLAIN ANALYZE
SELECT *
FROM layertype
where parentid = 300;
The planner weighs the cost of the different access methods and
choses the one that it believes is lowest in cost. An index scan is
not always faster than a sequential scan. With so few rows, it's
probably faster for the server to read the whole table rather than
reading the index and looking up the corresponding row. If you want
to test this, you can set enable_seqscan to false and try running
your query again.
http://www.postgresql.org/docs/8.2/interactive/runtime-config-
query.html#RUNTIME-CONFIG-QUERY-ENABLE
Michael Glaesemann
grzm seespotcode net