index and seq scan

From: Tina Messmann <tina(dot)messmann(at)xinux(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: index and seq scan
Date: 2002-01-10 16:50:21
Message-ID: 3C3DC64D.5090907@xinux.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello List,

i have the following table with an index on appid:

dbl=# \d test
Table "test"
Attribute | Type | Modifier

-----------+--------------------------+-------------------------------------------------
id | integer | not null default
nextval('"test_id_seq"'::text)
time | timestamp with time zone |
appid | integer |
Indices: appid_idx,
test_id_key

dbl=# \d appid_idx
Index "appid_idx"
Attribute | Type
-----------+---------
appid | integer
btree

Ii want this index to be used in my query, but only the seq. scan is
used and i don't know why.
When changing the WHERE expression to 'appid < 10', the index is used
(see EXPLAIN command below).
Could someone please explain this behavior to me and how i can use the
index in the first query?

dbl=# explain select * from test where appid > 10;
NOTICE: QUERY PLAN:
Seq Scan on test (cost=0.00..1530.84 rows=81050 width=16)
EXPLAIN

db=# explain select * from test where appid > 10;
NOTICE: QUERY PLAN:
Index Scan using appid_idx on test (cost=0.00..70.20 rows=57 width=16)
EXPLAIN

regards
Tina

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Darley 2002-01-10 16:55:50 Re: Performance tips
Previous Message will trillich 2002-01-10 16:47:12 Re: caching subtotals: update vs sum -- aaugh!