Re: obtaining ARRAY position for a given match

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Scott Bailey <artacus(at)comcast(dot)net>
Cc: Postgresql Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: obtaining ARRAY position for a given match
Date: 2009-11-19 17:43:38
Message-ID: b42b73150911190943w4ffc2b2bk38fef13239b61d9e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Nov 19, 2009 at 12:15 PM, Scott Bailey <artacus(at)comcast(dot)net> wrote:
>>   FROM generate_series(array_lover($1,1),array_upper($1,1)) g(i)
>
> Pavel,
>
> Don't get me wrong, I enjoy coding, but I think you've taken it too far here
> ;)
>
> Yes, definitely more effective for large arrays. Thanks. Would probably be a
> good snippet for the wiki.

this was actually a pretty typical solution to dealing with arrays
until we got 'unnest()'. See information_schema._pg_expand_array for
example.

I need this functionality quite often...maybe we could use a version
of unnest that works like that (returns idx, elem)? It would be a
small efficiency win over generate_series based approaches.

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Bailey 2009-11-19 17:46:42 Re: obtaining ARRAY position for a given match
Previous Message Scott Bailey 2009-11-19 17:15:35 Re: obtaining ARRAY position for a given match