slow 'IN' clause

From: FavoYang(at)gmail(dot)com
To: pgsql-sql(at)postgresql(dot)org
Subject: slow 'IN' clause
Date: 2006-04-10 03:44:34
Message-ID: 1144640674.181974.108190@u72g2000cwu.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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-sql by date

  From Date Subject
Next Message mike 2006-04-10 15:09:57 how to use recursion to find end nodes of a tree
Previous Message Michael Glaesemann 2006-04-10 01:14:07 Re: Modeling trees with Nested Sets and Nested Intervals