regarding IN clause

From: "Surabhi Ahuja " <surabhi(dot)ahuja(at)iiitb(dot)ac(dot)in>
To: <pgsql-general(at)postgresql(dot)org>
Subject: regarding IN clause
Date: 2005-05-18 05:12:36
Message-ID: CE5C48E227F8ED4990FAC4332100ADC621B534@EVS.iiitb.ac.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a table where the primary key "id" is a serial key.

now i have a query to this table where in, i have to get information related to a set of ids.
This set contains around 130 ids.

I was thinking that i can form a select statement of the form

select * from table where id in(4,8,9,12, and so on....);
i was testing this query on the table with 3000 rows only...
and when i did
explain analyze select * from table where id in(4,8,9,12, and so on....);..
it said that it was doing a sequential scan.

why is it not searching the indexes(index scan)? and how can i make such a query much faster?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dann Corbit 2005-05-18 05:26:06 Re: regarding IN clause
Previous Message Tom Lane 2005-05-18 03:03:57 Re: What should I do with this: invalid page header in block ... ?