pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Arkin <arkin@exoffice.com>
To: Peter Mount <petermount@it.maidstone.gov.uk>
Cc: 'Guillaume Rousse' <Guillaume.Rousse@univ-reunion.fr>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: Is this usage correct ?
Date: Wed, 19 Apr 2000 13:11:02 -0700
Message-ID: <38FE12D6.B4274285@exoffice.com> (raw )
References: <1B3D5E532D18D311861A00600865478C70C4D0@exchange1.nt.maidstone.gov.uk >
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
view thread (5+ messages) latest in thread
Message-ID: <38FE12D6.B4274285@exoffice.com>
Permalink: ../38FE12D6.B4274285@exoffice.com/
Also on: postgresql.org/message-id/38FE12D6.B4274285@exoffice.com
copy link · copy postgr.es
reply 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 using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: arkin@exoffice.com, petermount@it.maidstone.gov.uk, Guillaume.Rousse@univ-reunion.fr
Subject: Re: Is this usage correct ?
In-Reply-To: <38FE12D6.B4274285@exoffice.com>
* 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