Hello,

First, excuse me for my english. I have 33 tables ( with millions rows ) and
for most tables i use btree index. My problem is when
i use explain directive. In fact btree index work only
with operator "=" . eg: select * from test where id = 45
EXPLAIN
Index scan using idx_id on test
an doesn't work with select * from test where id < 45.
EXPLAIN
Seq scan on test
Why ???

Thanks

Search Discussions

  • Tom Lane at Oct 11, 2000 at 2:38 pm

    <pejac@altern.org> writes:
    an doesn't work with select * from test where id < 45.
    EXPLAIN
    Seq scan on test
    The system doesn't believe that WHERE clause is selective enough to be
    efficiently done as an indexscan. An indexscan will be slower than a
    seqscan unless it is able to visit just a small fraction of the rows
    in the table, and a one-sided inequality doesn't guarantee that.

    If 45 happens to be near the bottom of the range of ID values in this
    table, then indeed an indexscan might be a reasonable implementation.
    But the planner won't know the range of values unless you've done a
    VACUUM ANALYZE on this table.

    regards, tom lane

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-novice @
categoriespostgresql
postedOct 11, '00 at 7:47a
activeOct 11, '00 at 2:38p
posts2
users2
websitepostgresql.org
irc#postgresql

2 users in discussion

Tom Lane: 1 post Pejac: 1 post

People

Translate

site design / logo © 2022 Grokbase