pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Is this usage correct ?
5+ messages / 3 participants
[nested] [flat]

* Is this usage correct ?
@ 2000-04-19 09:47 Guillaume Rousse <Guillaume.Rousse@univ-reunion.fr>
  0 siblings, 0 replies; 5+ messages in thread

From: Guillaume Rousse @ 2000-04-19 09:47 UTC (permalink / raw)
  To: pgsql-interfaces

Is it correct to use a preparedStatement with no variable element, as this:
PreparedStatement stmp=conn.prepareStatement("delete from table where
oid="+oid);
stmt.excuteUpdate();

Or is it mandatory to use :
PreparedStatement stmp=conn.prepareStatement("delete from table where
oid=?");
stmt.setInt(1,oid);
stmt.excuteUpdate();

 -- 
Guillaume Rousse
Iremia - Université de la Réunion

Sleep doesn't exists. Just lack of cafeine.



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

* RE: Is this usage correct ?
@ 2000-04-19 10:26 Peter Mount <petermount@it.maidstone.gov.uk>
  2000-04-19 12:03 ` RE: Is this usage correct ? Guillaume Rousse <Guillaume.Rousse@univ-reunion.fr>
  2000-04-19 20:11 ` Re: Is this usage correct ? Arkin <arkin@exoffice.com>
  0 siblings, 2 replies; 5+ messages in thread

From: Peter Mount @ 2000-04-19 10:26 UTC (permalink / raw)
  To: 'Guillaume Rousse' <Guillaume.Rousse@univ-reunion.fr>; pgsql-interfaces

In theory it would be ok, but as PreparedStatement extends Statement,
why cause the extra overhead and just use Statement?

Peter

-- 
Peter Mount
Enterprise Support
Maidstone Borough Council
Any views stated are my own, and not those of Maidstone Borough Council.



-----Original Message-----
From: Guillaume Rousse [mailto:Guillaume.Rousse@univ-reunion.fr]
Sent: Wednesday, April 19, 2000 10:47 AM
To: pgsql-interfaces@postgresql.org
Subject: [INTERFACES] Is this usage correct ?


Is it correct to use a preparedStatement with no variable element, as
this:
PreparedStatement stmp=conn.prepareStatement("delete from table where
oid="+oid);
stmt.excuteUpdate();

Or is it mandatory to use :
PreparedStatement stmp=conn.prepareStatement("delete from table where
oid=?");
stmt.setInt(1,oid);
stmt.excuteUpdate();

 -- 
Guillaume Rousse
Iremia - Université de la Réunion

Sleep doesn't exists. Just lack of cafeine.



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

* RE: Is this usage correct ?
  2000-04-19 10:26 RE: Is this usage correct ? Peter Mount <petermount@it.maidstone.gov.uk>
@ 2000-04-19 12:03 ` Guillaume Rousse <Guillaume.Rousse@univ-reunion.fr>
  1 sibling, 0 replies; 5+ messages in thread

From: Guillaume Rousse @ 2000-04-19 12:03 UTC (permalink / raw)
  To: pgsql-interfaces; +Cc: Peter Mount <petermount@it.maidstone.gov.uk>

Just as i use PreparedStatement elsewhere in the code, i'd like to use the same
pattern.

 Le mer, 19 avr 2000, Peter Mount a écrit :
> In theory it would be ok, but as PreparedStatement extends Statement,
> why cause the extra overhead and just use Statement?
> 
> Peter
> 
> -- 
> Peter Mount
> Enterprise Support
> Maidstone Borough Council
> Any views stated are my own, and not those of Maidstone Borough Council.
> 
> 
> 
> -----Original Message-----
> From: Guillaume Rousse [mailto:Guillaume.Rousse@univ-reunion.fr]
> Sent: Wednesday, April 19, 2000 10:47 AM
> To: pgsql-interfaces@postgresql.org
> Subject: [INTERFACES] Is this usage correct ?
> 
> 
> Is it correct to use a preparedStatement with no variable element, as
> this:
> PreparedStatement stmp=conn.prepareStatement("delete from table where
> oid="+oid);
> stmt.excuteUpdate();
> 
> Or is it mandatory to use :
> PreparedStatement stmp=conn.prepareStatement("delete from table where
> oid=?");
> stmt.setInt(1,oid);
> stmt.excuteUpdate();
> 
>  -- 
> Guillaume Rousse
> Iremia - Université de la Réunion
> 
> Sleep doesn't exists. Just lack of cafeine.
-- 
Guillaume Rousse
Iremia - Université de la Réunion

Sleep doesn't exists. Just lack of cafeine.



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

* Re: Is this usage correct ?
  2000-04-19 10:26 RE: Is this usage correct ? Peter Mount <petermount@it.maidstone.gov.uk>
@ 2000-04-19 20:11 ` Arkin <arkin@exoffice.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Arkin @ 2000-04-19 20:11 UTC (permalink / raw)
  To: Peter Mount <petermount@it.maidstone.gov.uk>; +Cc: 'Guillaume Rousse' <Guillaume.Rousse@univ-reunion.fr>; pgsql-interfaces

Most RDBMS support two modes of queries. Statements and prepared
statements.

Statements are SQL strings that are parsed and processed in one go.
Prepared statements are pre-prepared and can be reused any number of
times. Since parameters tend to change across method invocation, they
support bound parameters (the '?' thingy).

In terms of performance statements are slightly faster if used only once
(Oracle 7) and prepared statements are way faster if used twice or more
times (Oracle 7 again). The RDMBS will construct a query plan during
preperation and only once for a given statement, thus saving a
non-marginal cost (especially if the query is rather complex). In fact,
in some instances where the results of a query are less than 100 records
(w/o long binary/char fields), using prepared statement can achive an
80% performance improvement.

arkin



Peter Mount wrote:
> 
> In theory it would be ok, but as PreparedStatement extends Statement,
> why cause the extra overhead and just use Statement?
> 
> Peter
> 
> --
> Peter Mount
> Enterprise Support
> Maidstone Borough Council
> Any views stated are my own, and not those of Maidstone Borough Council.
> 
> -----Original Message-----
> From: Guillaume Rousse [mailto:Guillaume.Rousse@univ-reunion.fr]
> Sent: Wednesday, April 19, 2000 10:47 AM
> To: pgsql-interfaces@postgresql.org
> Subject: [INTERFACES] Is this usage correct ?
> 
> Is it correct to use a preparedStatement with no variable element, as
> this:
> PreparedStatement stmp=conn.prepareStatement("delete from table where
> oid="+oid);
> stmt.excuteUpdate();
> 
> Or is it mandatory to use :
> PreparedStatement stmp=conn.prepareStatement("delete from table where
> oid=?");
> stmt.setInt(1,oid);
> stmt.excuteUpdate();
> 
>  --
> Guillaume Rousse
> Iremia - Université de la Réunion
> 
> Sleep doesn't exists. Just lack of cafeine.

-- 
----------------------------------------------------------------------
Assaf Arkin                                           www.exoffice.com
CTO, Exoffice Technologies, Inc.                        www.exolab.org



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

* RE: Is this usage correct ?
@ 2000-04-20 07:55 Peter Mount <petermount@it.maidstone.gov.uk>
  0 siblings, 0 replies; 5+ messages in thread

From: Peter Mount @ 2000-04-20 07:55 UTC (permalink / raw)
  To: 'Arkin' <arkin@exoffice.com>; Peter Mount <petermount@it.maidstone.gov.uk>; +Cc: 'Guillaume Rousse' <Guillaume.Rousse@univ-reunion.fr>; pgsql-interfaces

This is one of the reasons why I said Statement is better. The other
reason, is because postgresql doesn't yet support them, we currently do
the substitution in the driver, which is a large overhead compared with
Statement.

Peter

-- 
Peter Mount
Enterprise Support
Maidstone Borough Council
Any views stated are my own, and not those of Maidstone Borough Council.



-----Original Message-----
From: Arkin [mailto:arkin@exoffice.com]
Sent: Wednesday, April 19, 2000 9:11 PM
To: Peter Mount
Cc: 'Guillaume Rousse'; pgsql-interfaces@postgresql.org
Subject: Re: [INTERFACES] Is this usage correct ?


Most RDBMS support two modes of queries. Statements and prepared
statements.

Statements are SQL strings that are parsed and processed in one go.
Prepared statements are pre-prepared and can be reused any number of
times. Since parameters tend to change across method invocation, they
support bound parameters (the '?' thingy).

In terms of performance statements are slightly faster if used only once
(Oracle 7) and prepared statements are way faster if used twice or more
times (Oracle 7 again). The RDMBS will construct a query plan during
preperation and only once for a given statement, thus saving a
non-marginal cost (especially if the query is rather complex). In fact,
in some instances where the results of a query are less than 100 records
(w/o long binary/char fields), using prepared statement can achive an
80% performance improvement.

arkin



Peter Mount wrote:
> 
> In theory it would be ok, but as PreparedStatement extends Statement,
> why cause the extra overhead and just use Statement?
> 
> Peter
> 
> --
> Peter Mount
> Enterprise Support
> Maidstone Borough Council
> Any views stated are my own, and not those of Maidstone Borough
Council.
> 
> -----Original Message-----
> From: Guillaume Rousse [mailto:Guillaume.Rousse@univ-reunion.fr]
> Sent: Wednesday, April 19, 2000 10:47 AM
> To: pgsql-interfaces@postgresql.org
> Subject: [INTERFACES] Is this usage correct ?
> 
> Is it correct to use a preparedStatement with no variable element, as
> this:
> PreparedStatement stmp=conn.prepareStatement("delete from table where
> oid="+oid);
> stmt.excuteUpdate();
> 
> Or is it mandatory to use :
> PreparedStatement stmp=conn.prepareStatement("delete from table where
> oid=?");
> stmt.setInt(1,oid);
> stmt.excuteUpdate();
> 
>  --
> Guillaume Rousse
> Iremia - Université de la Réunion
> 
> Sleep doesn't exists. Just lack of cafeine.

-- 
----------------------------------------------------------------------
Assaf Arkin                                           www.exoffice.com
CTO, Exoffice Technologies, Inc.                        www.exolab.org



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


end of thread, other threads:[~2000-04-20 07:55 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-04-19 09:47 Is this usage correct ? Guillaume Rousse <Guillaume.Rousse@univ-reunion.fr>
2000-04-19 10:26 RE: Is this usage correct ? Peter Mount <petermount@it.maidstone.gov.uk>
2000-04-19 12:03 ` Guillaume Rousse <Guillaume.Rousse@univ-reunion.fr>
2000-04-19 20:11 ` Arkin <arkin@exoffice.com>
2000-04-20 07:55 RE: Is this usage correct ? Peter Mount <petermount@it.maidstone.gov.uk>

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