X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 098E811F6AA9 for ; Mon, 10 Apr 2006 00:44:44 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 0.55 X-Spam-Level: X-Spam-Status: No, score=0.55 required=5 tests=[NO_REAL_NAME=0.55] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id oYBjSwCeJBrE for ; Mon, 10 Apr 2006 00:44:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 65F7111F621C for ; Mon, 10 Apr 2006 00:44:41 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id E8BC530D11; Mon, 10 Apr 2006 05:44:39 +0200 (MET DST) From: FavoYang@gmail.com X-Newsgroups: pgsql.sql Subject: slow 'IN' clause Date: 9 Apr 2006 20:44:34 -0700 Organization: http://groups.google.com Lines: 10 Message-ID: <1144640674.181974.108190@u72g2000cwu.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Complaints-To: groups-abuse@google.com User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Firefox/1.0.7 (Debian package 1.0.7-1),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: u72g2000cwu.googlegroups.com; posting-host=221.122.43.98; posting-account=WVvL5A0AAAD4eKbsP0Kalew21Vv8aQF8 To: pgsql-sql@postgresql.org X-Archive-Number: 200604/77 X-Sequence-Number: 24886 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)