Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 9F06DB5DBE0 for ; Wed, 25 May 2011 15:55:37 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 53576-03 for ; Wed, 25 May 2011 18:55:30 +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 91DABB5DBF0 for ; Wed, 25 May 2011 15:55:25 -0300 (ADT) Received: by lerner.co.il (Postfix, from userid 1003) id 65BAB5D6D76; Wed, 25 May 2011 21:45:59 +0300 (IDT) X-DKIM: Sendmail DKIM Filter v2.8.3 lerner.co.il 65BAB5D6D76 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lerner.co.il; s=MAILOUT; t=1306349159; bh=aBjWwtBKumO46AAceLiMuVMck2Uq/+xOB7MaZYrTIbk=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=WYl0/iU1qmx8BqNCfXSO/lZNu6lBh9pVCsq6GJ6CbIER/pGWr/2OESTx6HsD9VZf+ Icle/THxVOBuvQy8Axw9lJgU2XxcrGxk9/KiNZQjCXLQDcd+o/0BaAwNK+ck5pl6S0 gN8FxK1nUs0hYkNHpfHqfMIpSnjqD2wXdfNBYF38= Received: from 2-54-48-204.orange.net.il (unknown [2.54.48.204]) by lerner.co.il (Postfix) with ESMTPS id 3DBCB5D6157; Wed, 25 May 2011 21:45:49 +0300 (IDT) X-DKIM: Sendmail DKIM Filter v2.8.3 lerner.co.il 3DBCB5D6157 Message-ID: <4DDD4E57.7070800@lerner.co.il> Date: Wed, 25 May 2011 21:45:43 +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: Alex Hunsaker CC: pgsql-performance@postgresql.org Subject: Re: Speeding up loops in pl/pgsql function References: <4DDD358E.20307@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: 201105/341 X-Sequence-Number: 43850 Hi, Alex. You wrote: > Have you tried something like: > SELECT encode(regexp_replace('141142143', '(\d{3})', '\\\1', > 'g')::bytea, 'escape'); Hmm, forgot about regexp_replace. It might do the trick, but without a full-blown eval that I can run on the replacement side, it'll be a bit more challenging. But that's a good direction to consider, for sure. > I think select E'\XXX' is what you are looking for (per the fine > manual: http://www.postgresql.org/docs/current/static/datatype-binary.html) I didn't think that I could (easily) build a string like that from digits in a variable or a column, but I'll poke around and see if it can work. Thanks, Reuven -- Reuven M. Lerner -- Web development, consulting, and training Mobile: +972-54-496-8405 * US phone: 847-230-9795 Skype/AIM: reuvenlerner