The oracle optimizer should not take long for an uncached query that's only using one table.

It is true that a hard parse for a complex SQL statement takes more time than for a simple SQL statement.

However, doing a hard parse always takes more time than not doing it, and in some cases the parsing overhead is the dominating factor for the total execution time. All I wanted to say, therefore is that hard parsing has to be avoided, and that is exactly what bind variables are for.

Especially if the tables have been analyzed

Actually, I should think that building an execution plan is faster if the tables have not been analyzed. In the absence of statistics (gathered during an analyze), Oracle has to skip all its clever calculations and defaults to some hard-coded heuristics.

Of course, the quality of the resulting execution plan will suffer, so spending some extra time on gathering table statistics and using them is a good thing (And you can profit most from this extra cost when re-using the execution plan over and over by having bind variables)

So, to sum up, not using bind variables is absolutely killing your Oracle performance, and if you run queries in a loop, you should also give prepare_cached some serious considerations.


In reply to Re^4: Question About Proper Use of Bind Variables in Perl DBI Scripts by Thilosophy
in thread Question About Proper Use of Bind Variables in Perl DBI Scripts by JPD

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.