Re: Seamless replacement to MySQL's GROUP_CONCAT function...
От | Pavel Stehule |
---|---|
Тема | Re: Seamless replacement to MySQL's GROUP_CONCAT function... |
Дата | |
Msg-id | CAFj8pRD0-J-_c_bL7AAazuo+W4QhcRfJjOFkOpKpPnXRUjNUXw@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Seamless replacement to MySQL's GROUP_CONCAT function... (Alvaro Herrera <alvherre@2ndquadrant.com>) |
Ответы |
Re: Seamless replacement to MySQL's GROUP_CONCAT function...
|
Список | pgsql-general |
2013/8/6 Alvaro Herrera <alvherre@2ndquadrant.com>: > Pavel Stehule escribió: > >> you code can be translated to >> >> CREATE OR REPLACE >> FUNCTION GROUP_CONCAT_ATOM(field1 TEXT, field2 TEXT, delimiter TEXT) >> RETURNS TEXT AS $$ >> BEGIN >> RETURN COALESCE(field1||delimiter||field2, field2, field1); >> END; >> $$ LANGUAGE plpgsql; > > Actually you don't even need plpgsql for this, do you .. There is better optimized plpgsql - not sure, why - probably, so there is not possible inlining .. and start of SQL engine is little bit slower than start of plpgsql. postgres=# create table f(a text, b int); CREATE TABLE postgres=# insert into f select 'Ahoj', random()*100 from generate_series(1,10000); select group_concat(a,',') from f group by b; PL/pgSQL .. 36 ms SQL .. 49 ms Regards Pavel Stehule > > -- > Álvaro Herrera http://www.2ndQuadrant.com/ > PostgreSQL Development, 24x7 Support, Training & Services
В списке pgsql-general по дате отправления: