Re: Converting each item in array to a query result row

From: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
To: Adam Ruth <adamruth(at)mac(dot)com>
Cc: Postgres User <postgres(dot)developer(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Converting each item in array to a query result row
Date: 2009-05-29 10:55:08
Message-ID: 2f4958ff0905290355g6a1216b2s154a883a25c9445f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

why complicate so much ? this is a single sql query. It really shocks
me, how people easily lean on plpgsql and for/loops - which are times
slower than simple sql query:

CREATE FUNCTION unnest(anyarray) RETURNS SETOF anyelement AS
$_$
SELECT ($1)[i] FROM generate_series(array_lower($1,1),array_upper($1,1)) i;
$_$
LANGUAGE sql IMMUTABLE;

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nico Sabbi 2009-05-29 11:13:42 Re: I can't drop a user if I don't drop his grants beforehand??????????????????
Previous Message Geoffrey 2009-05-29 10:35:49 Re: Please remove me from the list!