I've seen various ways in sqlplus to time queries. Here is a simple one:

set autotrace on; set timing on; select count(*) from table; COUNT(*) ---------- 164078859 Elapsed: 00:01:02.02 Execution Plan ---------------------------------------------------------- Plan hash value: 2319838783 ---------------------------------------------------------------------- +------- | Id | Operation | Name | Rows | Cost (%CPU)| Time + | ---------------------------------------------------------------------- +------- | 0 | SELECT STATEMENT | | 1 | 87965 (2)| 00:17: +36 | | 1 | SORT AGGREGATE | | 1 | | | | 2 | INDEX FAST FULL SCAN| PRICE_IDX18 | 152M| 87965 (2)| 00 +:17:36 | ---------------------------------------------------------------------- +------- Statistics ---------------------------------------------------------- 1 recursive calls 0 db block gets 321153 consistent gets 321106 physical reads 0 redo size 422 bytes sent via SQL*Net to client 420 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed

Using Perl DBI you can quickly do something like:

use DBI; use strict; use warnings; use Benchmark; my $h = DBI->connect('dbi:Oracle:host=xxx;sid=yyy','xxx','xxx'); my $s = $h->prepare(q/select * from action where action_id = ?/); timethese(10000, { 'placeholders' => sub {placeholders($s)}, 'quote' => sub {quote($h)}}); sub placeholders { $_[0]->execute(1); } sub quote { $s = $h->prepare("select * from action where action_id = " . $_[0] +->quote(1)); $s->execute; }
$ perl bm.pl Benchmark: timing 10000 iterations of placeholders, quote... placeholders: 3 wallclock secs ( 0.43 usr + 0.20 sys = 0.63 CPU) @ +15873.02/s (n=10000) quote: 16 wallclock secs ( 5.51 usr + 1.32 sys = 6.83 CPU) @ 14 +64.13/s (n=10000)

In reply to Re^5: DBI, place holders and CGI forms by mje
in thread DBI, place holders and CGI forms by Anonymous Monk

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.