X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 782CD9FA6B7 for ; Fri, 15 Sep 2006 17:19:27 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 06041-03 for ; Fri, 15 Sep 2006 20:19:24 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id F23839FA2E5 for ; Fri, 15 Sep 2006 17:19:23 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k8FKJLGU005374; Fri, 15 Sep 2006 16:19:21 -0400 (EDT) To: Benjamin Minshall cc: pgsql-performance@postgresql.org Subject: Re: Performance of IN (...) vs. = ANY array[...] In-reply-to: <450AFB07.5050600@intellicon.biz> References: <450AFB07.5050600@intellicon.biz> Comments: In-reply-to Benjamin Minshall message dated "Fri, 15 Sep 2006 15:12:07 -0400" Date: Fri, 15 Sep 2006 16:19:21 -0400 Message-ID: <5373.1158351561@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.011 tagged_above=0 required=5 tests=BIZ_TLD, SPF_HELO_PASS, SPF_PASS X-Spam-Level: ** X-Archive-Number: 200609/213 X-Sequence-Number: 20899 Benjamin Minshall writes: > What are the advantages or disadvantages of using arrays in this > situation? The = ANY array method makes plpgsql development cleaner, > but seems to really lack performance in certain cases. In existing releases, the form with IN (list-of-scalar-constants) can be optimized into indexscan(s), but = ANY (array) isn't. 8.2 will treat them equivalently (in fact, it converts IN (...) to = ANY (ARRAY[...]) !). So depending on your time horizon, you might wish to stick with whichever is cleaner for your calling code. regards, tom lane