Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 27EDFB622F7 for ; Thu, 2 Jun 2011 03:49:45 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 09292-04 for ; Thu, 2 Jun 2011 06:49:37 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lerner.co.il (unknown [69.55.231.201]) by mail.postgresql.org (Postfix) with ESMTP id 93228B6234C for ; Thu, 2 Jun 2011 03:49:37 -0300 (ADT) Received: by lerner.co.il (Postfix, from userid 1003) id 7F19B5D6673; Thu, 2 Jun 2011 09:49:35 +0300 (IDT) X-DKIM: Sendmail DKIM Filter v2.8.3 lerner.co.il 7F19B5D6673 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lerner.co.il; s=MAILOUT; t=1306997375; bh=iQKwOYJ7sJMGkJehooOGFbJWbl88f1fGc/Zkn4IcEa0=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=jKQ9qawqCcu92cx1FFJmb/Fk8pit0oyc8+W9UOePY+BvsHrTKGfkbgG4ozb9ZMqg0 WHnXXe/rrGt1hJJJyzb1FBbRMHqZLzueNxa1//LkP5xEuUYVaiZ73iNNumKBiydNAT 4qGm9HWSMUqgXpmVSbtXW8oKM/9ciXYWdGpF6BZk= Received: from MacBookPro.local (bzq-84-109-188-144.red.bezeqint.net [84.109.188.144]) by lerner.co.il (Postfix) with ESMTPS id 7646F5D6104; Thu, 2 Jun 2011 09:49:29 +0300 (IDT) X-DKIM: Sendmail DKIM Filter v2.8.3 lerner.co.il 7646F5D6104 Message-ID: <4DE73277.9010308@lerner.co.il> Date: Thu, 02 Jun 2011 09:49:27 +0300 From: "Reuven M. Lerner" User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: Merlin Moncure CC: Steve Crawford , Alex Hunsaker , pgsql-performance@postgresql.org Subject: Re: Speeding up loops in pl/pgsql function References: <4DDD358E.20307@lerner.co.il> <4DDD4E57.7070800@lerner.co.il> <4DDD98B6.6080208@pinpointresearch.com> <4DE60422.3090800@lerner.co.il> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.107 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RDNS_NONE=0.793 X-Spam-Level: X-Archive-Number: 201106/16 X-Sequence-Number: 43949 Hi, Merlin. You wrote: > select string_agg(v, '') from (select > ascii(regexp_split_to_table('abc', $$\s*$$))::text as v) q; Wow. I've been programming with pl/pgsql for a good number of years, but only now do I see the amazing usefulness of regexp_split_to_table and string_agg, neither of which I really used until now. Thanks for both the solution and for opening my eyes. > (what about 3 digit ascii codes?) I have to put the number into a text field anyway, so I've been converting the resulting number to text, and then using lpad to add leading zeroes as necessary. Thanks again, Reuven -- Reuven M. Lerner -- Web development, consulting, and training Mobile: +972-54-496-8405 * US phone: 847-230-9795 Skype/AIM: reuvenlerner