Thread: PQunescapeBytea tweak

PQunescapeBytea tweak

From
Adam Kavan
Date:
This patch converts PQunescapeBytea from using arrays to the text string
and to the output binary string to using pointers.  This makes it much
faster than the older version for large Bytea's.

--- Adam Kavan
--- akavan@cox.net

Attachment

Re: PQunescapeBytea tweak

From
Bruce Momjian
Date:
Is this against 7.3.X or 7.4beta?  Also, we prefer diff -c.

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

Adam Kavan wrote:
> This patch converts PQunescapeBytea from using arrays to the text string
> and to the output binary string to using pointers.  This makes it much
> faster than the older version for large Bytea's.
>
> --- Adam Kavan
> --- akavan@cox.net

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly

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

Re: PQunescapeBytea tweak

From
Tom Lane
Date:
Adam Kavan <akavan@cox.net> writes:
> This patch converts PQunescapeBytea from using arrays to the text string
> and to the output binary string to using pointers.  This makes it much
> faster than the older version for large Bytea's.

What compiler and optimization settings are you using, and what is the
hardware platform?  It seems strange to me that you would get any
noticeable speedup from this change.  Most C compilers are supposed to
be reasonably smart about optimizing subscripted pointers.

Also, how about using tmpbuf as the moving pointer, instead of
interchanging the roles of tmpbuf and buffer as you did?  That
seems a bit confusing.

Finally, as Bruce noted, we prefer diff -c output for patches.
It's safer to apply that way --- the plain diff format fails
too easily if there have been any nearby changes.

            regards, tom lane

Re: PQunescapeBytea tweak

From
Adam Kavan
Date:
At 09:57 PM 10/30/03 -0500, Tom Lane wrote:
>What compiler and optimization settings are you using, and what is the
>hardware platform?  It seems strange to me that you would get any
>noticeable speedup from this change.  Most C compilers are supposed to
>be reasonably smart about optimizing subscripted pointers.

Whoops, my code was linking against an old 7.3.x version of libpq, the
speed is the same compared to 7.4.

--- Adam Kavan
--- akavan@cox.net