X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id E8B1111F66F2 for ; Mon, 10 Apr 2006 00:43:51 -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 i7Hw97pPToh1 for ; Mon, 10 Apr 2006 00:43:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id C418D11F621C for ; Mon, 10 Apr 2006 00:43:49 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 1ADA130D11; Mon, 10 Apr 2006 05:43:49 +0200 (MET DST) From: FavoYang@gmail.com X-Newsgroups: pgsql.performance Subject: slow "IN" clause Date: 9 Apr 2006 20:43:40 -0700 Organization: http://groups.google.com Lines: 10 Message-ID: <1144640620.925899.274170@z34g2000cwc.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: z34g2000cwc.googlegroups.com; posting-host=221.122.43.98; posting-account=WVvL5A0AAAD4eKbsP0Kalew21Vv8aQF8 To: pgsql-performance@postgresql.org X-Archive-Number: 200604/224 X-Sequence-Number: 18308 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)