Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> REPOST: Re: Why Oracle always reparses anonymous blocks?

REPOST: Re: Why Oracle always reparses anonymous blocks?

From: Sebastiano Pilla <etechweb_at_yahoo.com>
Date: Sat, 29 Dec 2001 10:18:34 +0100
Message-ID: <3$--$$-$$_%%$%$_-$@news.noc.cabal.int>


Thomas Kyte <tkyte_at_us.oracle.com> wrote:

> It is upto the programmer to ensure a block is parsed only ONCE per
> program, not once per execution.
>
> I see this lots in java, the developers open a callable statement (that
> PARSES it, it'll be a soft parse, not as bad as a hard but still overhead
> and inhibits scalability), bind to it (if we are lucky), execute it and
> then close it.
>
> They should:
>
> open it once per session.
>
> bind it / execute it many times over and over.
>
> close it or just disconnect, that'll close it.
>
> then you will see the parse count go waaaayyy down.

Is this the correct thing to do even when (in Java) using pooled connections? We are using pooled connection with OC4J and Oracle 8.1.7 JDBC drivers, and many code samples that I've seen recommend to close the statement and the logical connection after the execution.

For example, after doing something like:

stmt = connection.prepareCall(...);
stmt.setString(...);
rset = stmt.executeQuery();

we do (in a finally block):

rset.close();
stmt.close();
connection.close();

to return the logical connection to the pool. The next time we ask for a logical connection, the pool may give us a completely different "physical" connection to the database: what to do in this case? I don't know (and I won't be able to try until 1/7) if the statement reference is still meaningful after closing the connection it was obtained from. Do you recommend to leave the stmt reference in the above pseudo-code as a class-scoped variable (as opposed to a method-scoped variable)?

(BTW: OC4J 1.0.2.2.1, Oracle 8.1.7 [patched to 8.1.7.2 IIRC], Windows 2000 SP2)

Thanks for any pointers.
Sebastiano Pilla

This message was cancelled from within Mozilla...not Received on Sat Dec 29 2001 - 03:18:34 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US