OSDN Git Service

I made the patch that improved the performance of replace_text().
authorBruce Momjian <bruce@momjian.us>
Mon, 4 Jul 2005 18:56:44 +0000 (18:56 +0000)
committerBruce Momjian <bruce@momjian.us>
Mon, 4 Jul 2005 18:56:44 +0000 (18:56 +0000)
commit109f079be65b1d5e725e117ba2764af72007cc3b
tree40c244335ab3f269e1d84f44cad3d939a4ef3795
parent4b97d51c0a17f8da5335772bc9ee13a4154894fd
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
src/backend/utils/adt/varlena.c