Helo, i have one problem, i have two arrays and want to check its values in mysql databases. i wrote this script, but when here is 30000 queries
[SNIP]
foreach $a1(@a1) { foreach $b1(@b1) { $sth = $dbh->prepare( "SELECT a1.ID FROM a1, a1_b1, b1 WH

In addition to the excellent answers you got thus far, I have a pair of remarks that nobody seems to have done yet:

  1. this is not "your script", but a portion of it. So far so fine, but to help people who will read your post it is generally recommended to build a minimal but complete example still exhibiting the problem (often in the course of doing so one actually solves the problem, but I doubt this could have been the case here);
  2. you may have noticed that at the top of many people's example code they inserted the following two lines:
    use strict; use warnings;
    I recommed you to do the same. They instruct perl to restrict your freedom in a way that will help you to avoid common programming mistakes, hence implicitly to give you all the help it can. Of course you will then have to declare your (lexical) variables with my.

  3. In reply to Re: how to speed up querys to mysql by blazar
    in thread how to speed up querys to mysql by rycagaa

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



  4. Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  5. Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  6. Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  7. Please read these before you post! —
  8. 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
  9. 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;
  10. Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  11. See Writeup Formatting Tips and other pages linked from there for more info.