in reply to Re: search an array
in thread search an array

Or even change the SQL to SELECT count(*) FROM v\$process WHERE spid = $xpid so you get immediately the number of records in the database for which spid = $xpid. It is faster, it saves on memory and you can plug it straight into the if.

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Replies are listed 'Best First'.
Re^3: search an array
by Anonymous Monk on May 26, 2006 at 13:03 UTC
    This is fine provided you know the values of all the $xpid (there could be thousands) prior to issuing the SQL. The problem is I don't. This means that I would have to issue a select every time I search for a spid which isn't as cost effective as getting the whole list up front and letting Perl do the search (I know ... I've tested it). It's my fault for not expressing the question in as much detail as perhaps I should
      Just to make sure all the bases are covered, when you tried querying for each $xpid instead of slurping the entire database into memory, did you use a placeholder so you could prepare the statement once, then execute it repeatedly? If not, you might want to re-try your test, as it makes a big difference on an often-run query if it doesn't have to be re-prepared each time.