pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Stark <gsstark@mit.edu>
To: Joe Conway <mail@joeconway.com>
Cc: Richard Huxton <dev@archonet.com>
Cc: Andreas Tille <tillea@rki.de>
Cc: PostgreSQL SQL <pgsql-sql@postgresql.org>
Subject: Re: Scaler forms as function arguments
Date: 28 Nov 2003 11:48:04 -0500
Message-ID: <87llq0fni3.fsf@stark.dyndns.tv> (raw)
In-Reply-To: <3FC6E15E.2030300@joeconway.com>
References: <Pine.LNX.4.56.0311261255210.17774@wr-linux02.rki.ivbb.bund.de>
	<200311261725.21975.dev@archonet.com>
	<3FC6E15E.2030300@joeconway.com>


Joe Conway <mail@joeconway.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




view thread (8+ messages)

Message-ID: <87llq0fni3.fsf@stark.dyndns.tv>
Permalink:  ../87llq0fni3.fsf@stark.dyndns.tv/
Also on:    postgresql.org/message-id/87llq0fni3.fsf@stark.dyndns.tv

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gsstark@mit.edu, mail@joeconway.com, dev@archonet.com, tillea@rki.de
  Subject: Re: Scaler forms as function arguments
  In-Reply-To: <87llq0fni3.fsf@stark.dyndns.tv>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox