I must be missing something here, but why aren't you just storing all the properties for each element in memory, rather than querying the DB each time? Assuming you can allow 100MB of memory for this, and you have 70K elements, that's 1462 bytes per element, which should cover all your property needs. If it doesn't, allocate and/or buy more memory. This is by far the biggest time sinkhole right here.

Secondly, you should be able to generate the lowest "property pair" values by comparing your largest values with your smallest values, rather than doing a random selection. If you still want random output, exclude all pairs that will result in a value over your threshold (let's say you want 7, and item 1 has a value of 4, so anything with a value under 3 can be ignored), then choose from the resulting pool of pairs.

Anything else will just be polishing the finish.


In reply to Re: Benchmarking A DB-Intensive Script by TedPride
in thread Benchmarking A DB-Intensive Script by bernanke01

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.