replace_text() improvement

Lists: pgsql-patches
From: Atsushi Ogawa <a_ogawa(at)hi-ho(dot)ne(dot)jp>
To: pgsql-patches(at)postgresql(dot)org
Subject: replace_text() improvement
Date: 2005-06-14 13:16:05
Message-ID: PIEMIKOOMKNIJLLLBCBBMEFOCIAA.a_ogawa@hi-ho.ne.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


I made the patch that improved the performance of replace_text().
The content of the patch is as follows:

(1)Create shortcut when subtext was not found.

(2)Stop using LEFT and RIGHT macro.
In LEFT and RIGHT macro, TEXTPOS is executed by the same content as
execution immediately before. The execution frequency of TEXTPOS can be
reduced by using text_substring instead of LEFT and RIGHT macro.

(3)Add appendStringInfoText, and use it instead of appendStringInfoString.
There is an overhead of PG_TEXT_GET_STR when appendStringInfoString is
executed by text type. This can be reduced by appendStringInfoText.

(4)Reduce execution of TEXTDUP.

The effect of the patch that I measured is as follows:

- The Data for test was created by 'pgbench -i'.

- Test SQL:
select replace(aid, '9', 'A') from accounts;

- Test results: Linux(CPU: Pentium III, Compiler option: -O2)
original: 1.515s
patched: 1.250s

regards,

---
Atsushi Ogawa

Attachment Content-Type Size
replace_text.patch application/octet-stream 3.8 KB

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Atsushi Ogawa <a_ogawa(at)hi-ho(dot)ne(dot)jp>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: replace_text() improvement
Date: 2005-06-28 00:46:02
Message-ID: 200506280046.j5S0k2P09218@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

It will be applied as soon as one of the PostgreSQL committers reviews
and approves it.

---------------------------------------------------------------------------

Atsushi Ogawa wrote:
>
> I made the patch that improved the performance of replace_text().
> The content of the patch is as follows:
>
> (1)Create shortcut when subtext was not found.
>
> (2)Stop using LEFT and RIGHT macro.
> In LEFT and RIGHT macro, TEXTPOS is executed by the same content as
> execution immediately before. The execution frequency of TEXTPOS can be
> reduced by using text_substring instead of LEFT and RIGHT macro.
>
> (3)Add appendStringInfoText, and use it instead of appendStringInfoString.
> There is an overhead of PG_TEXT_GET_STR when appendStringInfoString is
> executed by text type. This can be reduced by appendStringInfoText.
>
> (4)Reduce execution of TEXTDUP.
>
> The effect of the patch that I measured is as follows:
>
> - The Data for test was created by 'pgbench -i'.
>
> - Test SQL:
> select replace(aid, '9', 'A') from accounts;
>
> - Test results: Linux(CPU: Pentium III, Compiler option: -O2)
> original: 1.515s
> patched: 1.250s
>
> regards,
>
> ---
> Atsushi Ogawa

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Atsushi Ogawa <a_ogawa(at)hi-ho(dot)ne(dot)jp>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: replace_text() improvement
Date: 2005-07-04 18:57:07
Message-ID: 200507041857.j64Iv7e03583@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


Patch applied. Thanks.

---------------------------------------------------------------------------

Atsushi Ogawa wrote:
>
> I made the patch that improved the performance of replace_text().
> The content of the patch is as follows:
>
> (1)Create shortcut when subtext was not found.
>
> (2)Stop using LEFT and RIGHT macro.
> In LEFT and RIGHT macro, TEXTPOS is executed by the same content as
> execution immediately before. The execution frequency of TEXTPOS can be
> reduced by using text_substring instead of LEFT and RIGHT macro.
>
> (3)Add appendStringInfoText, and use it instead of appendStringInfoString.
> There is an overhead of PG_TEXT_GET_STR when appendStringInfoString is
> executed by text type. This can be reduced by appendStringInfoText.
>
> (4)Reduce execution of TEXTDUP.
>
> The effect of the patch that I measured is as follows:
>
> - The Data for test was created by 'pgbench -i'.
>
> - Test SQL:
> select replace(aid, '9', 'A') from accounts;
>
> - Test results: Linux(CPU: Pentium III, Compiler option: -O2)
> original: 1.515s
> patched: 1.250s
>
> regards,
>
> ---
> Atsushi Ogawa

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073