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 -> Re: Slow Query in PL/SQL Block

Re: Slow Query in PL/SQL Block

From: Daniel <danielroy10junk_at_hotmail.com>
Date: 14 Aug 2005 06:50:07 -0700
Message-ID: <1124027406.998776.180890@g14g2000cwa.googlegroups.com>


Hi Brijesh,

   I'm not sure I understand your question properly, but I'd like to add to your post that SQL is USUALLY faster than the equivalent in PL/SQL (even though I've certainly seen exceptions, with properly-tuned PL/SQL). Your code, as written now, triggers a "context switch" from the PL/SQL engine to the SQL engine for each cursor row fetched. A context switch consists at a high level of storing everything needed for when the program control comes back to the PL/SQL or SQL engine
(SQL record count, PL/SQL user variable values, ...). If you decide to
stick to PL/SQL (as opposed to pure SQL) for whatever reason, use collections in order to minimize this context switching overhead. To make sure to not eat up all your (server) RAM, limit your bulk collects to 500 records, or possibly 200. Look in the PL/SQL programming
(chapter 5) of your Oracle version to find the exact syntax to use for
collections.

HTH Daniel Received on Sun Aug 14 2005 - 08:50:07 CDT

Original text of this message

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