Re: Scaler forms as function arguments

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Richard Huxton <dev(at)archonet(dot)com>, Andreas Tille <tillea(at)rki(dot)de>, PostgreSQL SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Scaler forms as function arguments
Date: 2003-11-28 16:48:04
Message-ID: 87llq0fni3.fsf@stark.dyndns.tv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Joe Conway <mail(at)joeconway(dot)com> 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-11-28 19:18:46 Re: explicit joins wrong planning
Previous Message FET 2003-11-28 09:20:21 Stored procedures and relations