slow "IN" clause

From: FavoYang(at)gmail(dot)com
To: pgsql-performance(at)postgresql(dot)org
Subject: slow "IN" clause
Date: 2006-04-10 03:43:40
Message-ID: 1144640620.925899.274170@z34g2000cwc.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

I have a slow sql:
SELECT * FROM mytable WHERE id IN (1,3,5,7,....3k here...);
mytable is about 10k rows.

if don't use the "IN" clause, it will cost 0,11 second, otherwise it
will cost 2.x second
I guess pg use linear search to deal with IN clause, is there any way
to let pg use other search method with IN clause? (ex.Binary Search or
hash Search)

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Qingqing Zhou 2006-04-10 04:44:46 Re: slow "IN" clause
Previous Message Alvaro Herrera 2006-04-09 22:01:53 Re: serious problems with vacuuming databases