pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PreparedStatement#setString on non-string parameters
14+ messages / 5 participants
[nested] [flat]

* PreparedStatement#setString on non-string parameters
@ 2005-03-08 11:06 Silvio Bierman <sbierman@jambo-software.com>
  2005-03-08 12:33 ` Re: PreparedStatement#setString on non-string parameters Dave Cramer <pg@fastcrypt.com>
  2005-03-08 13:20 ` Re: PreparedStatement#setString on non-string parameters Guillaume Cottenceau <gc@mnc.ch>
  2005-03-08 21:23 ` Re: PreparedStatement#setString on non-string parameters Oliver Jowett <oliver@opencloud.com>
  0 siblings, 3 replies; 14+ messages in thread

From: Silvio Bierman @ 2005-03-08 11:06 UTC (permalink / raw)
  To: pgsql-jdbc

Hello all,

I have just finished a few hours of testing our product that already runs on
Oracle, SQLServer, MySQL, MaxDB and McKOI on PostgreSQL. I always liked what
I read about this database apart from the fact that it used to not run
natively on Windows. Since many of our customers run Windows servers I never
bothered with PostgreSQL before.

However, starting with version 8 there is a native Windows version which I
installed and ran our product on. At first everything was fine and I was
very impressed with both the performance as the ease of use of the admin
tools.

But when I starting doing writes to the database SQL exceptions started to
occur. They where all over the application code but where all the same
error: doing a setString on a numeric parameter. I know this is usually
suboptimal but since we handle a lot of XML data throughout the (heavily
distributed) application many numeric values are available as Strings so it
would be a matter of converting them to numeric values ourselves or letting
the JDBC driver do that.

The JDBC drivers we used for the other databasse I mentioned never
complained. Unfortunately PostgreSQL does. I read somewhere that using the
pre-version-8 JDBC driver will work with 8 and not show this behaviour, the
8 driver has deliberately changed the behaviour.

The JDBC spec requires the driver to attempt a conversion when a
setString is done on a non-string parameter. This will break a lot of
conformant code, not only ours. Is there any chance this can be corrected?

Regards,

Silvio Bierman




^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: PreparedStatement#setString on non-string parameters
  2005-03-08 11:06 PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
@ 2005-03-08 12:33 ` Dave Cramer <pg@fastcrypt.com>
  2005-03-08 12:56   ` Re: PreparedStatement#setString on non-string parameters Guillaume Cottenceau <gc@mnc.ch>
  2 siblings, 1 reply; 14+ messages in thread

From: Dave Cramer @ 2005-03-08 12:33 UTC (permalink / raw)
  To: Silvio Bierman <sbierman@jambo-software.com>; +Cc: pgsql-jdbc

Silvio,

I presume you are talking about setObject ??? I can't find a 
setString(non-string param)

Dave

Silvio Bierman wrote:

>Hello all,
>
>I have just finished a few hours of testing our product that already runs on
>Oracle, SQLServer, MySQL, MaxDB and McKOI on PostgreSQL. I always liked what
>I read about this database apart from the fact that it used to not run
>natively on Windows. Since many of our customers run Windows servers I never
>bothered with PostgreSQL before.
>
>However, starting with version 8 there is a native Windows version which I
>installed and ran our product on. At first everything was fine and I was
>very impressed with both the performance as the ease of use of the admin
>tools.
>
>But when I starting doing writes to the database SQL exceptions started to
>occur. They where all over the application code but where all the same
>error: doing a setString on a numeric parameter. I know this is usually
>suboptimal but since we handle a lot of XML data throughout the (heavily
>distributed) application many numeric values are available as Strings so it
>would be a matter of converting them to numeric values ourselves or letting
>the JDBC driver do that.
>
>The JDBC drivers we used for the other databasse I mentioned never
>complained. Unfortunately PostgreSQL does. I read somewhere that using the
>pre-version-8 JDBC driver will work with 8 and not show this behaviour, the
>8 driver has deliberately changed the behaviour.
>
>The JDBC spec requires the driver to attempt a conversion when a
>setString is done on a non-string parameter. This will break a lot of
>conformant code, not only ours. Is there any chance this can be corrected?
>
>Regards,
>
>Silvio Bierman
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
>               http://archives.postgresql.org
>
>
>  
>

-- 
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561




^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: PreparedStatement#setString on non-string parameters
  2005-03-08 11:06 PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
  2005-03-08 12:33 ` Re: PreparedStatement#setString on non-string parameters Dave Cramer <pg@fastcrypt.com>
@ 2005-03-08 12:56   ` Guillaume Cottenceau <gc@mnc.ch>
  2005-03-08 13:09     ` Re: PreparedStatement#setString on non-string parameters Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 14+ messages in thread

From: Guillaume Cottenceau @ 2005-03-08 12:56 UTC (permalink / raw)
  To: pg@fastcrypt.com; +Cc: Silvio Bierman <sbierman@jambo-software.com>; pgsql-jdbc

Dave Cramer <pg 'at' fastcrypt.com> writes:

> Silvio,
> 
> I presume you are talking about setObject ??? I can't find a
> setString(non-string param)

He says "XML data (..) many numeric values are available as
Strings" so I think the SQL column is numeric but the rest is
string (a java string containing the string representation of the
numeric value).

-- 
Guillaume Cottenceau



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: PreparedStatement#setString on non-string parameters
  2005-03-08 11:06 PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
  2005-03-08 12:33 ` Re: PreparedStatement#setString on non-string parameters Dave Cramer <pg@fastcrypt.com>
  2005-03-08 12:56   ` Re: PreparedStatement#setString on non-string parameters Guillaume Cottenceau <gc@mnc.ch>
@ 2005-03-08 13:09     ` Dave Cramer <pg@fastcrypt.com>
  0 siblings, 0 replies; 14+ messages in thread

From: Dave Cramer @ 2005-03-08 13:09 UTC (permalink / raw)
  To: Guillaume Cottenceau <gc@mnc.ch>; +Cc: Silvio Bierman <sbierman@jambo-software.com>; pgsql-jdbc

That makes sense.

I just checked my reference and I can't find any document that suggests 
that setString should do a conversion.

setObject is required to by the spec.

Dave

Guillaume Cottenceau wrote:

>Dave Cramer <pg 'at' fastcrypt.com> writes:
>
>  
>
>>Silvio,
>>
>>I presume you are talking about setObject ??? I can't find a
>>setString(non-string param)
>>    
>>
>
>He says "XML data (..) many numeric values are available as
>Strings" so I think the SQL column is numeric but the rest is
>string (a java string containing the string representation of the
>numeric value).
>
>  
>

-- 
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561




^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: PreparedStatement#setString on non-string parameters
  2005-03-08 11:06 PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
@ 2005-03-08 13:20 ` Guillaume Cottenceau <gc@mnc.ch>
  2 siblings, 0 replies; 14+ messages in thread

From: Guillaume Cottenceau @ 2005-03-08 13:20 UTC (permalink / raw)
  To: Silvio Bierman <sbierman@jambo-software.com>; +Cc: pgsql-jdbc

"Silvio Bierman" <sbierman 'at' jambo-software.com> writes:

[...]

> The JDBC spec requires the driver to attempt a conversion when a
> setString is done on a non-string parameter. This will break a lot of
> conformant code, not only ours. Is there any chance this can be corrected?

Where can you see that?

I can see pretty much the opposite, for example the following at
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/PreparedStatement.html

-=-=---=-=---=-=---=-=---=-=--
Note: The setter methods (setShort, setString, and so on) for
setting IN parameter values must specify types that are
compatible with the defined SQL type of the input parameter. For
instance, if the IN parameter has SQL type INTEGER, then the
method setInt should be used.
-=-=---=-=---=-=---=-=---=-=--

And even, at
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/PreparedStatement.html#setString(int,%20java.lang.S...)

-=-=---=-=---=-=---=-=---=-=--
setString: The driver converts this to an SQL VARCHAR or
LONGVARCHAR value (depending on the argument's size relative to
the driver's limits on VARCHAR values) when it sends it to the
database.
-=-=---=-=---=-=---=-=---=-=--

-- 
Guillaume Cottenceau



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: PreparedStatement#setString on non-string parameters
  2005-03-08 11:06 PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
@ 2005-03-08 21:23 ` Oliver Jowett <oliver@opencloud.com>
  2 siblings, 0 replies; 14+ messages in thread

From: Oliver Jowett @ 2005-03-08 21:23 UTC (permalink / raw)
  To: Silvio Bierman <sbierman@jambo-software.com>; +Cc: pgsql-jdbc

Silvio Bierman wrote:

> The JDBC spec requires the driver to attempt a conversion when a
> setString is done on a non-string parameter. This will break a lot of
> conformant code, not only ours. Is there any chance this can be corrected?

AFAIK, the spec doesn't require this. Can you point me at the bit of the 
spec that makes you think it does?

As I read the spec, the only conversions the driver performs for IN 
parameters are those in table B-2 (for String, to 
CHAR/VARCHAR/LONGVARCHAR) or B-4 (same mapping for String). See 13.2.2.1 
and 13.2.2.2 of the JDBC 3.0 spec.

There is a wider set of conversions available on the ResultSet path 
(notably, integer -> string) -- see 14.2.3.1 and table B-6.

-O



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* FW: PreparedStatement#setString on non-string parameters
@ 2005-03-08 21:23 Silvio Bierman <sbierman@jambo-software.com>
  2005-03-08 21:47 ` Re: FW: PreparedStatement#setString on non-string parameters Oliver Jowett <oliver@opencloud.com>
  2005-03-09 17:04 ` Re: FW: PreparedStatement#setString on non-string parameters Guillaume Cottenceau <gc@mnc.ch>
  0 siblings, 2 replies; 14+ messages in thread

From: Silvio Bierman @ 2005-03-08 21:23 UTC (permalink / raw)
  To: pgsql-jdbc

Sorry, I originally sent sent this in a reply to a message CC-ed to me
directly...

-----Original Message-----
From: Silvio Bierman [mailto:sbierman@jambo-software.com]
Sent: Tuesday, March 08, 2005 2:51 PM
To: pg@fastcrypt.com
Subject: RE: [JDBC] PreparedStatement#setString on non-string parameters


Hello Dave,

Thanks for the reply and thanks to Guillaume for clearing up my not very
well expressed intentions. I was indeed talking about using
setString(String) where the parameter refers to a numeric value.

The way I read the spec only conversions from Java types to SQL types are
specified. Explicitly the specification says that setObject(Object) should
use the dynamic Java type of the object to determine the conversion. No
extra interpretation of the prepared statement logic is required by
setObject. It is merely a more generic way of setting parameters on the Java
side instead of implying extra interpretation logic.

I guess striktly speaking the spec does not say what should happend when a
driver maps a Java String to SQL VARCHAR and the corresponding parameter is
expected by the database to be numeric. It is probably just like passing a

select count(*) from table where integercol='3'

to a database. Should it do the implicit conversion?

Either the JDBC drivers for the databases I mentioned earlier do the
conversion or the database backends do it on the server side. Any way, this
works in all cases. PostgreSQL is the first database to break our
application due to this behaviour. We have had problems on earlier versions
of MySQL because of lack of subselect support etc. but never these issues.

I really love what I have seen of PostgreSQL until now and I am seriously
considering making it our preferred database backend. The ability to run on
both Linux and Windows is great, performance is excellent (I tried a quite
large database) even when I am still inserting my GUID keys as varchar data
and the admin tool is very good also.

Telling my users to use an old JDBC driver is not an option though...

Regards,

Silvio Bierman


@-----Original Message-----
@From: pgsql-jdbc-owner@postgresql.org
@[mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Dave Cramer
@Sent: Tuesday, March 08, 2005 2:10 PM
@To: Guillaume Cottenceau
@Cc: Silvio Bierman; PostgreSQL JDBC
@Subject: Re: [JDBC] PreparedStatement#setString on non-string parameters
@
@
@That makes sense.
@
@I just checked my reference and I can't find any document that suggests
@that setString should do a conversion.
@
@setObject is required to by the spec.
@
@Dave
@
@Guillaume Cottenceau wrote:
@
@>Dave Cramer <pg 'at' fastcrypt.com> writes:
@>
@>
@>
@>>Silvio,
@>>
@>>I presume you are talking about setObject ??? I can't find a
@>>setString(non-string param)
@>>
@>>
@>
@>He says "XML data (..) many numeric values are available as
@>Strings" so I think the SQL column is numeric but the rest is
@>string (a java string containing the string representation of the
@>numeric value).
@>
@>
@>
@
@--
@Dave Cramer
@http://www.postgresintl.com
@519 939 0336
@ICQ#14675561
@
@
@---------------------------(end of broadcast)---------------------------
@TIP 4: Don't 'kill -9' the postmaster




^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: FW: PreparedStatement#setString on non-string parameters
  2005-03-08 21:23 FW: PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
@ 2005-03-08 21:47 ` Oliver Jowett <oliver@opencloud.com>
  2005-03-09 03:58   ` Re: FW: PreparedStatement#setString on non-string parameters Antony Paul <antonypaul24@gmail.com>
  1 sibling, 1 reply; 14+ messages in thread

From: Oliver Jowett @ 2005-03-08 21:47 UTC (permalink / raw)
  To: Silvio Bierman <sbierman@jambo-software.com>; +Cc: pgsql-jdbc

Silvio Bierman wrote:

> Either the JDBC drivers for the databases I mentioned earlier do the
> conversion or the database backends do it on the server side. Any way, this
> works in all cases. PostgreSQL is the first database to break our
> application due to this behaviour. We have had problems on earlier versions
> of MySQL because of lack of subselect support etc. but never these issues.

I'd suggest using CAST in your SQL -- that in theory should work 
everywhere and reflects your application's intent (to interpret a string 
as a numeric value).

The problem with reverting to the old way of doing parameters (direct 
text substitution into the query) is that we cannot take advantage of 
most of the new stuff in the V3 protocol -- that means no server-side 
prepared statement reuse, no low-overhead transfer of large parameters, 
and reduced support for cursor-based resultsets.

-O



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: FW: PreparedStatement#setString on non-string parameters
  2005-03-08 21:23 FW: PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
  2005-03-08 21:47 ` Re: FW: PreparedStatement#setString on non-string parameters Oliver Jowett <oliver@opencloud.com>
@ 2005-03-09 03:58   ` Antony Paul <antonypaul24@gmail.com>
  2005-03-09 09:08     ` Re: FW: PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
  0 siblings, 1 reply; 14+ messages in thread

From: Antony Paul @ 2005-03-09 03:58 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: Silvio Bierman <sbierman@jambo-software.com>; pgsql-jdbc

Does this new stuff added in 8.0 driver adds to performance ?. I had
this setString() problem and I tested 7.4.x driver which works and
performs better than 8.0 driver.



On Wed, 09 Mar 2005 10:47:34 +1300, Oliver Jowett <oliver@opencloud.com> wrote:
> Silvio Bierman wrote:
> 
> > Either the JDBC drivers for the databases I mentioned earlier do the
> > conversion or the database backends do it on the server side. Any way, this
> > works in all cases. PostgreSQL is the first database to break our
> > application due to this behaviour. We have had problems on earlier versions
> > of MySQL because of lack of subselect support etc. but never these issues.
> 
> I'd suggest using CAST in your SQL -- that in theory should work
> everywhere and reflects your application's intent (to interpret a string
> as a numeric value).
> 
> The problem with reverting to the old way of doing parameters (direct
> text substitution into the query) is that we cannot take advantage of
> most of the new stuff in the V3 protocol -- that means no server-side
> prepared statement reuse, no low-overhead transfer of large parameters,
> and reduced support for cursor-based resultsets.
> 
> -O
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match
> 


-- 
rgds
Antony Paul
http://www.geocities.com/antonypaul24/



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: FW: PreparedStatement#setString on non-string parameters
  2005-03-08 21:23 FW: PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
  2005-03-08 21:47 ` Re: FW: PreparedStatement#setString on non-string parameters Oliver Jowett <oliver@opencloud.com>
  2005-03-09 03:58   ` Re: FW: PreparedStatement#setString on non-string parameters Antony Paul <antonypaul24@gmail.com>
@ 2005-03-09 09:08     ` Silvio Bierman <sbierman@jambo-software.com>
  2005-03-09 09:14       ` Re: FW: PreparedStatement#setString on non-string parameters Antony Paul <antonypaul24@gmail.com>
  2005-03-09 13:26       ` Re: FW: PreparedStatement#setString on non-string parameters Oliver Jowett <oliver@opencloud.com>
  0 siblings, 2 replies; 14+ messages in thread

From: Silvio Bierman @ 2005-03-09 09:08 UTC (permalink / raw)
  To: pgsql-jdbc; Antony Paul <antonypaul24@gmail.com>

Hello Antony,

I honestly don't know. Oliver Jowett told me that the 8.0 driver is the
first to use server side prepared statements, which is good I guess. I do
not know the internals of PostgreSQL server statement caching but usually
using server side prepared statements is faster than emulating prepared
statements in the JDBC driver. In cases where statements are really
exectuted once only and the PreparedStatement is used for parameter
substitution convenience only (which is a very good reason, BTW) emulated
statements are usually faster.

I just tested with the 7.4 driver and that actually works fine. It also
fixed the setString error I got when using the James mail server with the
8.0 driver...

I can not say anything about performance in comparison to the 8.0 driver
yet. Oliver mentioned poor blob-performance in the pre-8 protocol. I am not
very happy with that since we use blobs quite frequently, be it that they
are are never very large.

I will be doing some tests with the 8.0 driver in combination with a
implicit cast versus the 7.4 driver. I will keep you posted...

Regards,

Silvio Bierman



@-----Original Message-----
@From: pgsql-jdbc-owner@postgresql.org
@[mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Antony Paul
@Sent: Wednesday, March 09, 2005 4:59 AM
@To: Oliver Jowett
@Cc: Silvio Bierman; PostgreSQL JDBC
@Subject: Re: FW: [JDBC] PreparedStatement#setString on non-string
@parameters
@
@
@Does this new stuff added in 8.0 driver adds to performance ?. I had
@this setString() problem and I tested 7.4.x driver which works and
@performs better than 8.0 driver.
@
@
@
@On Wed, 09 Mar 2005 10:47:34 +1300, Oliver Jowett
@<oliver@opencloud.com> wrote:
@> Silvio Bierman wrote:
@>
@> > Either the JDBC drivers for the databases I mentioned earlier do the
@> > conversion or the database backends do it on the server side.
@Any way, this
@> > works in all cases. PostgreSQL is the first database to break our
@> > application due to this behaviour. We have had problems on
@earlier versions
@> > of MySQL because of lack of subselect support etc. but never
@these issues.
@>
@> I'd suggest using CAST in your SQL -- that in theory should work
@> everywhere and reflects your application's intent (to interpret a string
@> as a numeric value).
@>
@> The problem with reverting to the old way of doing parameters (direct
@> text substitution into the query) is that we cannot take advantage of
@> most of the new stuff in the V3 protocol -- that means no server-side
@> prepared statement reuse, no low-overhead transfer of large parameters,
@> and reduced support for cursor-based resultsets.
@>
@> -O
@>
@> ---------------------------(end of broadcast)---------------------------
@> TIP 9: the planner will ignore your desire to choose an index
@scan if your
@>       joining column's datatypes do not match
@>
@
@
@--
@rgds
@Antony Paul
@http://www.geocities.com/antonypaul24/
@
@---------------------------(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




^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: FW: PreparedStatement#setString on non-string parameters
  2005-03-08 21:23 FW: PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
  2005-03-08 21:47 ` Re: FW: PreparedStatement#setString on non-string parameters Oliver Jowett <oliver@opencloud.com>
  2005-03-09 03:58   ` Re: FW: PreparedStatement#setString on non-string parameters Antony Paul <antonypaul24@gmail.com>
  2005-03-09 09:08     ` Re: FW: PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
@ 2005-03-09 09:14       ` Antony Paul <antonypaul24@gmail.com>
  2005-03-09 13:23         ` Re: FW: PreparedStatement#setString on non-string parameters Oliver Jowett <oliver@opencloud.com>
  1 sibling, 1 reply; 14+ messages in thread

From: Antony Paul @ 2005-03-09 09:14 UTC (permalink / raw)
  To: Silvio Bierman <sbierman@jambo-software.com>; +Cc: pgsql-jdbc

The performance difference I noticed when it is scanning a table of
150k records with a long query containing a lot of or conditions. The
difference is around 10-12 seconds. So I think it is not the time
taken to prepare the statement. I wasnt interested in further
investigation as we dropped the plan of upgrading still 8.x becomes
9-12 months old.

rgds
Antony Paul


On Wed, 9 Mar 2005 10:08:10 +0100, Silvio Bierman
<sbierman@jambo-software.com> wrote:
> Hello Antony,
> 
> I honestly don't know. Oliver Jowett told me that the 8.0 driver is the
> first to use server side prepared statements, which is good I guess. I do
> not know the internals of PostgreSQL server statement caching but usually
> using server side prepared statements is faster than emulating prepared
> statements in the JDBC driver. In cases where statements are really
> exectuted once only and the PreparedStatement is used for parameter
> substitution convenience only (which is a very good reason, BTW) emulated
> statements are usually faster.
> 
> I just tested with the 7.4 driver and that actually works fine. It also
> fixed the setString error I got when using the James mail server with the
> 8.0 driver...
> 
> I can not say anything about performance in comparison to the 8.0 driver
> yet. Oliver mentioned poor blob-performance in the pre-8 protocol. I am not
> very happy with that since we use blobs quite frequently, be it that they
> are are never very large.
> 
> I will be doing some tests with the 8.0 driver in combination with a
> implicit cast versus the 7.4 driver. I will keep you posted...
> 
> Regards,
> 
> Silvio Bierman
> 
> @-----Original Message-----
> @From: pgsql-jdbc-owner@postgresql.org
> @[mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Antony Paul
> @Sent: Wednesday, March 09, 2005 4:59 AM
> @To: Oliver Jowett
> @Cc: Silvio Bierman; PostgreSQL JDBC
> @Subject: Re: FW: [JDBC] PreparedStatement#setString on non-string
> @parameters
> @
> @
> @Does this new stuff added in 8.0 driver adds to performance ?. I had
> @this setString() problem and I tested 7.4.x driver which works and
> @performs better than 8.0 driver.
> @
> @
> @
> @On Wed, 09 Mar 2005 10:47:34 +1300, Oliver Jowett
> @<oliver@opencloud.com> wrote:
> @> Silvio Bierman wrote:
> @>
> @> > Either the JDBC drivers for the databases I mentioned earlier do the
> @> > conversion or the database backends do it on the server side.
> @Any way, this
> @> > works in all cases. PostgreSQL is the first database to break our
> @> > application due to this behaviour. We have had problems on
> @earlier versions
> @> > of MySQL because of lack of subselect support etc. but never
> @these issues.
> @>
> @> I'd suggest using CAST in your SQL -- that in theory should work
> @> everywhere and reflects your application's intent (to interpret a string
> @> as a numeric value).
> @>
> @> The problem with reverting to the old way of doing parameters (direct
> @> text substitution into the query) is that we cannot take advantage of
> @> most of the new stuff in the V3 protocol -- that means no server-side
> @> prepared statement reuse, no low-overhead transfer of large parameters,
> @> and reduced support for cursor-based resultsets.
> @>
> @> -O
> @>
> @> ---------------------------(end of broadcast)---------------------------
> @> TIP 9: the planner will ignore your desire to choose an index
> @scan if your
> @>       joining column's datatypes do not match
> @>
> @
> @
> @--
> @rgds
> @Antony Paul
> @http://www.geocities.com/antonypaul24/
> @
> @---------------------------(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
> 
> 


-- 
rgds
Antony Paul
http://www.geocities.com/antonypaul24/



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: FW: PreparedStatement#setString on non-string parameters
  2005-03-08 21:23 FW: PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
  2005-03-08 21:47 ` Re: FW: PreparedStatement#setString on non-string parameters Oliver Jowett <oliver@opencloud.com>
  2005-03-09 03:58   ` Re: FW: PreparedStatement#setString on non-string parameters Antony Paul <antonypaul24@gmail.com>
  2005-03-09 09:08     ` Re: FW: PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
  2005-03-09 09:14       ` Re: FW: PreparedStatement#setString on non-string parameters Antony Paul <antonypaul24@gmail.com>
@ 2005-03-09 13:23         ` Oliver Jowett <oliver@opencloud.com>
  0 siblings, 0 replies; 14+ messages in thread

From: Oliver Jowett @ 2005-03-09 13:23 UTC (permalink / raw)
  To: Antony Paul <antonypaul24@gmail.com>; +Cc: Silvio Bierman <sbierman@jambo-software.com>; pgsql-jdbc

Antony Paul wrote:
> The performance difference I noticed when it is scanning a table of
> 150k records with a long query containing a lot of or conditions. The
> difference is around 10-12 seconds. So I think it is not the time
> taken to prepare the statement. I wasnt interested in further
> investigation as we dropped the plan of upgrading still 8.x becomes
> 9-12 months old.

There are some performance implications of pushing parameter management 
to the server side: under 7.4.x, a prepared statement does not gain the 
benefit of knowing the concrete parameter values used in a particular 
query execution, which can affect the plan chosen (if a concrete value 
for a parameter isn't known, the index selectivity estimates may not be 
as good).

In theory this should not be an issue if you set prepareThreshold=0 
(either globally on the connection, or via setPrepareTheshold on the 
statement in question) to prevent reuse of server statements, and use an 
8.0.x server. 8.0 defers the planning of unnamed (not reused) statements 
until actual parameter values are available, which may improve the plan 
chosen for that particular execution.

If it's not that, I'd need a testcase to be able to investigate this 
further.

-O



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: FW: PreparedStatement#setString on non-string parameters
  2005-03-08 21:23 FW: PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
  2005-03-08 21:47 ` Re: FW: PreparedStatement#setString on non-string parameters Oliver Jowett <oliver@opencloud.com>
  2005-03-09 03:58   ` Re: FW: PreparedStatement#setString on non-string parameters Antony Paul <antonypaul24@gmail.com>
  2005-03-09 09:08     ` Re: FW: PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
@ 2005-03-09 13:26       ` Oliver Jowett <oliver@opencloud.com>
  1 sibling, 0 replies; 14+ messages in thread

From: Oliver Jowett @ 2005-03-09 13:26 UTC (permalink / raw)
  To: Silvio Bierman <sbierman@jambo-software.com>; +Cc: pgsql-jdbc; Antony Paul <antonypaul24@gmail.com>

Silvio Bierman wrote:

> I can not say anything about performance in comparison to the 8.0 driver
> yet. Oliver mentioned poor blob-performance in the pre-8 protocol. I am not
> very happy with that since we use blobs quite frequently, be it that they
> are are never very large.

The protocol actually changed in 7.4, but the JDBC driver was not 
updated to use all the features of the new protocol until the 8.0 
release cycle.

-O



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: FW: PreparedStatement#setString on non-string parameters
  2005-03-08 21:23 FW: PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
@ 2005-03-09 17:04 ` Guillaume Cottenceau <gc@mnc.ch>
  1 sibling, 0 replies; 14+ messages in thread

From: Guillaume Cottenceau @ 2005-03-09 17:04 UTC (permalink / raw)
  To: Silvio Bierman <sbierman@jambo-software.com>; +Cc: pgsql-jdbc

"Silvio Bierman" <sbierman 'at' jambo-software.com> writes:

> Either the JDBC drivers for the databases I mentioned earlier do the
> conversion or the database backends do it on the server side. Any way, this
> works in all cases. PostgreSQL is the first database to break our
> application due to this behaviour. We have had problems on earlier versions

But you understand it's not breaking the JDBC spec, though.

> of MySQL because of lack of subselect support etc. but never these issues.
> 
> I really love what I have seen of PostgreSQL until now and I am seriously
> considering making it our preferred database backend. The ability to run on
> both Linux and Windows is great, performance is excellent (I tried a quite
> large database) even when I am still inserting my GUID keys as varchar data
> and the admin tool is very good also.
>
> Telling my users to use an old JDBC driver is not an option though...

But telling the developers to follow the JDBC specs is definitely
an option :). Understand me: I know that there can be a real pile
of existing code that did run before, and is broken now by this
change. However, you cannot ask developers implementing a
specification to intentionally break the specification because
others drivers and old version did so.

-- 
Guillaume Cottenceau



^ permalink  raw  reply  [nested|flat] 14+ messages in thread


end of thread, other threads:[~2005-03-09 17:04 UTC | newest]

Thread overview: 14+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-03-08 11:06 PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
2005-03-08 12:33 ` Dave Cramer <pg@fastcrypt.com>
2005-03-08 12:56   ` Guillaume Cottenceau <gc@mnc.ch>
2005-03-08 13:09     ` Dave Cramer <pg@fastcrypt.com>
2005-03-08 13:20 ` Guillaume Cottenceau <gc@mnc.ch>
2005-03-08 21:23 ` Oliver Jowett <oliver@opencloud.com>
2005-03-08 21:23 FW: PreparedStatement#setString on non-string parameters Silvio Bierman <sbierman@jambo-software.com>
2005-03-08 21:47 ` Oliver Jowett <oliver@opencloud.com>
2005-03-09 03:58   ` Antony Paul <antonypaul24@gmail.com>
2005-03-09 09:08     ` Silvio Bierman <sbierman@jambo-software.com>
2005-03-09 09:14       ` Antony Paul <antonypaul24@gmail.com>
2005-03-09 13:23         ` Oliver Jowett <oliver@opencloud.com>
2005-03-09 13:26       ` Oliver Jowett <oliver@opencloud.com>
2005-03-09 17:04 ` Guillaume Cottenceau <gc@mnc.ch>

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