OK, I see nothing obviously wrong in this snippet, but...
(Apologies if this is teaching you to suck eggs)
1. If your main concern is overall speed, I suggest some
detailed profiling. Find where the code is spending most
of its time. See Benchmark. Use the Benchmark->new and
timediff() methods to look at checkpoints. Since you are doing
lots of logging anyway, have your loggit() call put a timestamp
in the LOG.
- Prepare_cached is only going to save you time if it
takes a long time to do the actual prepare and you call it
lots of times. It could be that if the datasets are large
the time is taken in the execute(), and not the prepare().
-
Depending on your DB config, load on the server, and
systems could be a factor.
-
You seem to be collecting all the values and then only
using the first 15 or 10 lines. How about using a LIMIT command
to reduce the lines computed/returned by the SQL.
-
There may be other SQL/DB efficiency ideas, but I am not the person
to ask about that. I expect that a good time profile will
help you narrow down the issues better.
2. Have you turned on the error checking in the DB ?
{RaiseError=>1}
in the connect(). It could be that there is a problem in the
prepare() line.
3. Is it only failing if you use prepare_cached ? I.E. does it work
without the _cached ?
4. Are you using the $sth->finish() when no longer needed ? This
can generate errors if there is an open execute and _cached is called again.
That's all I can think of right now, good luck.
--
Brovnik
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.