I don't think all of your code got in here. Where did the
@old
come from? Also, make sure that you have indexes on your join fields. It looks like you are joining on one thing for one query for the first on and something different for the second one. Is this correct? Just from an efficiency standpoint, your code will run slower during that block of code because you are doing 2 exact comparisons and one date range. You might try creating a view before hand that has the date range already in it, then you can just query the view, and you won't have to rummage through the whole table looking for the information. Another way would be to run the first query as is, then run the second one without the ccode and number check, and then check the results once you get it all in memory against what you are looking for. Also, move your $db->prepare outside of your for loop. Since that query is static, there is no need to redeclare it every time. You will eat up the database SGA in a hurry!!!! Look at bind variables with DBI to get around the SGA/PGA stuff. Hope this helps you get started cheers! krazken

In reply to Re: VVP:Faster DBI'ing? by krazken
in thread VVP:Faster DBI'ing? by vivekvp

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.