Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 90505 invoked from network); 22 Jul 2010 08:29:48 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 22 Jul 2010 08:29:48 -0000 Received: (qmail 66683 invoked by uid 500); 22 Jul 2010 08:29:48 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 66466 invoked by uid 500); 22 Jul 2010 08:29:46 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 66459 invoked by uid 99); 22 Jul 2010 08:29:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jul 2010 08:29:45 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of marco.ferretti@gmail.com designates 74.125.82.50 as permitted sender) Received: from [74.125.82.50] (HELO mail-ww0-f50.google.com) (74.125.82.50) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jul 2010 08:29:38 +0000 Received: by wwe15 with SMTP id 15so2788187wwe.31 for ; Thu, 22 Jul 2010 01:29:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=mnFFWASWrgnpP3s0k56KFChdHRCaFBx8GyxPv2xRW8I=; b=P/xPZC1Wyh3AvgmcR4hhuw2cNjBtybDhtutHFaje7x9hpoOWW6NnQrSn+g8azF2lfW 3MTeqMzmajOzciZ1el1ejJH8uAersAa4DYdBiJ8jGdCl2JxBamq4ZrGmuI0Hf5YuKZPN 8UMqU8dgOgC5aS5h3VOCnhmWmAoeX4sBdefEI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=mZQ+0ayGVxcKZfH+o9lGT/lWdW5Hsj58pshHSUbgL5Ih5e4B1q1nKq6caa+lGL2rtd bAHYMGctAVjvARQFrmwigCkPGVBPfGTPPHndVgpZ0M8siWGzZOrSISPpfxCiNsCtvkou rgsCqhszipGuaqTx/qurYXReVFpISH7+As+L4= MIME-Version: 1.0 Received: by 10.227.145.201 with SMTP id e9mr1470950wbv.92.1279787358489; Thu, 22 Jul 2010 01:29:18 -0700 (PDT) Received: by 10.216.185.135 with HTTP; Thu, 22 Jul 2010 01:29:18 -0700 (PDT) In-Reply-To: References: Date: Thu, 22 Jul 2010 10:29:18 +0200 Message-ID: Subject: Re: Question about prepared statements From: Marco Ferretti To: Derby Discussion Content-Type: multipart/alternative; boundary=0016e6586522e40faf048bf5b63e X-Virus-Checked: Checked by ClamAV on apache.org --0016e6586522e40faf048bf5b63e Content-Type: text/plain; charset=ISO-8859-1 Thanks a lot for your quick answer !! On Thu, Jul 22, 2010 at 10:01 AM, Knut Anders Hatlen wrote: > Marco Ferretti writes: > > > Hello, > > I have a question on how derby works with prepared statements. > > > > The scenario : > > -1 connection (embedded driver) > > -1 prepared statement run several times over the database ( does not > matter if > > select, insert ... ) > > -I keep the connection open but close the prepared statement ( and make > sure > > it is garbage collected ) > > -On a later stage I create a new prepared statement with the same SQL as > the > > one mentioned before > > > > Question : > > Does derby re-use the pre-compiled SQL or is it creating another one ? > > Hi Marco, > > Derby keeps a cache of the most recently compiled statements (100 by > default, tunable with the derby.language.statementCacheSize property), > so if you later prepare a statement with the exact same SQL text, you'll > most likely re-use the pre-compiled SQL from the cache. > > -- > Knut Anders > --0016e6586522e40faf048bf5b63e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks a lot for your quick answer !!
=

On Thu, Jul 22, 2010 at 10:01 AM, Knu= t Anders Hatlen <knut.hatlen@oracle.com> wrote:
Marco Fer= retti <marco.ferretti@gmail.= com> writes:

> Hello,=A0
> I have a question on how derby works with prepared statements.
>
> The scenario :=A0
> -1 connection (embedded driver)
> -1 prepared statement run several times over the database ( does not m= atter if
> select, insert ... )=A0
> -I keep=A0the connection open but close the prepared statement ( and m= ake sure
> it is garbage collected )
> -On a later stage I create a new prepared statement with the same SQL = as the
> one mentioned before=A0
>
> Question :
> Does derby re-use the pre-compiled SQL or is it creating another one ?=

Hi Marco,

Derby keeps a cache of the most recently compiled statements (100 by
default, tunable with the derby.language.statementCacheSize property),
so if you later prepare a statement with the exact same SQL text, you'l= l
most likely re-use the pre-compiled SQL from the cache.

--
Knut Anders



--0016e6586522e40faf048bf5b63e--