X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1D13FD1B444 for ; Fri, 28 Nov 2003 16:48:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 60602-03 for ; Fri, 28 Nov 2003 12:48:17 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id D6795D1B4A6 for ; Fri, 28 Nov 2003 12:48:16 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id E3BF636E8C; Fri, 28 Nov 2003 11:48:05 -0500 (EST) Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) id 1APlmn-0000Wr-00; Fri, 28 Nov 2003 11:48:05 -0500 To: Joe Conway Cc: Richard Huxton , Andreas Tille , PostgreSQL SQL Subject: Re: Scaler forms as function arguments References: <200311261725.21975.dev@archonet.com> <3FC6E15E.2030300@joeconway.com> In-Reply-To: <3FC6E15E.2030300@joeconway.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 28 Nov 2003 11:48:04 -0500 Message-ID: <87llq0fni3.fsf@stark.dyndns.tv> Lines: 26 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/310 X-Sequence-Number: 16125 Joe Conway writes: > In 7.4 you could use an array. It would look like this: Though note that 7.4 doesn't know how to optimize this form: db=> explain select * from foo where foo_id in (1,2); QUERY PLAN ----------------------------------------------------------------------------------------------------------------- Index Scan using foo_pkey, foo_pkey on foo (cost=0.00..6.05 rows=2 width=756) Index Cond: ((foo_id = 1) OR (foo_id = 2)) (2 rows) db=> explain select * from foo where foo_id = ANY (array[1,2]); QUERY PLAN ---------------------------------------------------------------------- Seq Scan on foo (cost=0.00..1132.82 rows=5955 width=756) Filter: (foo_id = ANY ('{1,2}'::integer[])) (2 rows) -- greg