From: Michael Paesold <mpaesold@gmx.at>
To: Dave Cramer <pg@fastcrypt.com>
Cc: pgsql-jdbc@postgresql.org
Cc: Kris Jurka <books@ejurka.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: [pgsql-jdbc] dollar-quoted CREATE FUNCTION statement fails
Date: Thu, 02 Nov 2006 02:19:48 +0100
Message-ID: <454947B4.40509@gmx.at> (raw)
In-Reply-To: <014CC1FC-95DA-413F-976B-3C753B448EB2@fastcrypt.com>
References: <53F8133C991FEC4BA0872D19BAD9694C3B6A70@ADV-SBS.advestigo.loc>
<451BAE61.6070802@gmx.at>
<11DE4B3E-F76F-42C8-A5A6-2C63E14458AD@fastcrypt.com>
<451EBBCF.1030902@gmx.at>
<451FC6CD.6060904@gmx.at>
<4522DA56.4070105@gmx.at>
<Pine.BSO.4.63.0610031655110.31844@leary2.csoft.net>
<4526085F.5030604@gmx.at>
<Pine.BSO.4.63.0610300136580.17615@leary2.csoft.net>
<4545B34A.6050001@gmx.at>
<45491601.7050407@gmx.at>
<014CC1FC-95DA-413F-976B-3C753B448EB2@fastcrypt.com>
Hi Dave,
first, I forgot to say that I did do performance tests using the
previously posted test case. The new version is definitely faster than
the original code, although only marginally. When doing my first version
of the patch, I tested different code constructs for speed. I chose the
one with the best performance.
I ran the tests with both 1.4.2 and 1.5.0. It might be possible that the
performance will be worse in an earlier versions of the JDK with a less
sophisticated hot-spot compiler.
Dave Cramer wrote:
> Michael,
>
> I'm only looking at this from a performance standpoint.
>
> 1) testing for array.length in a loop is fairly expensive compared to
> testing for 0, not a big deal but it adds up.
Could you give me a hint what part of the code you were looking at? And
what you would want me to change? Do you think we should scan the query
backwards (testing the offset against zero -- not sure if this is a good
idea) or do you want to make the query char[] zero-terminated so that we
can test against '\0'?
Btw. changing the code to
int len = array.length;
for (....; i < len ; ...)
did not give any performance advantage for me. I think the compiler can
quite effectively optimize access to .length here.
> 2) I'm wondering what the cost of a switch is for two cases ( candidly I
> don't know the answer to this,and it's quite likely that modern
> compilers will turn it into an if else anyway.)
Hmm, perhaps it's bad coding style that I left out the empty default.
But I only see this example in the code (2 cases + an implicit default):
+ switch (query[offset])
+ {
+ case '\\':
+ ++offset;
+ break;
+ case '\'':
+ return offset;
+ }
That would really translate to:
if (query[offset] = '\\') ... else if (query[offset] = '\'') ... /* else
nothing */
Should I add an empty default in that code sections? When I originally
wrote that code, it was all in that main loop, so I wanted to keep it
short. Now that it is split into several methods, I see no reason for
brevity.
Best Regards,
Michael Paesold
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: mpaesold@gmx.at, pg@fastcrypt.com, books@ejurka.com, tgl@sss.pgh.pa.us
Subject: Re: [pgsql-jdbc] dollar-quoted CREATE FUNCTION statement fails
In-Reply-To: <454947B4.40509@gmx.at>
References: <53F8133C991FEC4BA0872D19BAD9694C3B6A70@ADV-SBS.advestigo.loc> <451BAE61.6070802@gmx.at> <11DE4B3E-F76F-42C8-A5A6-2C63E14458AD@fastcrypt.com> <451EBBCF.1030902@gmx.at> <451FC6CD.6060904@gmx.at> <4522DA56.4070105@gmx.at> <Pine.BSO.4.63.0610031655110.31844@leary2.csoft.net> <4526085F.5030604@gmx.at> <Pine.BSO.4.63.0610300136580.17615@leary2.csoft.net> <4545B34A.6050001@gmx.at> <45491601.7050407@gmx.at> <014CC1FC-95DA-413F-976B-3C753B448EB2@fastcrypt.com> <454947B4.40509@gmx.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox