The subroutine pasted below is part of a Perl DBI script that connects to an Oracle 9i database. This subroutine runs many times in a short time period.
My DBA tells me that Oracle is parsing the subroutine's query each time the subroutine runs.
Is there something I can do to encourage Oracle to save and re-use the execution plan for this query?
sub secIsNew {
# Given a PACE security ID, return 1 if that security is newly held,
# 0 if that security is not newly held.
use strict 'vars';
my($secId) = $_[0];
my($sth); # Statement handle
my($count); # Count returned by SQL select statements
my($sql) = "select count(*)
from analytics.an_security
where security_id = :1 and is_new = 'Y'";
$sth = $dbh->prepare($sql);
$sth->bind_param(1, $secId);
$sth->execute();
($count) = $sth->fetchrow_array;
return $count;
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.