pgsql: I made the patch that improved the performance of replace_text().

From: momjian(at)svr1(dot)postgresql(dot)org (Bruce Momjian)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: I made the patch that improved the performance of replace_text().
Date: 2005-07-04 18:56:44
Message-ID: 20050704185644.B060F528A8@svr1.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
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

Atsushi Ogawa

Modified Files:
--------------
pgsql/src/backend/utils/adt:
varlena.c (r1.123 -> r1.124)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/varlena.c.diff?r1=1.123&r2=1.124)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2005-07-04 19:03:31 pgsql: This patch allows the PL/Python module to do (SRF) functions.
Previous Message User Andrewd 2005-07-04 18:53:47 pgbuildfarm - client-code: ignore files listed in cvsignore files -