I have five sql tables with about 5,000 rows of data each. Each individual table represents a variable and the rows hold points in time (days) and a specific data point for that particular point in time. I need to create a script that will compare the differences in data points for all specific points in time across the five variables. For example for the date 1/1/2005 I need to compare the data points from table 1, table 2, table 3, table 4, and table 5. I need to do this for all the individual points in time (about 5,000).
I can think of two ways of going about this:
1. Create a simple loop that would iterate through the days, pull the data from each sql table, compare it, and set the appropriate flag depending on the results. Downside of this is that I would be making 25,000 (5,000*5) individual queries to my database.
2. Input all of the data from each sql table into hash structures upfront. Then create a loop that iterates through the days and compares the data. (i.e. if $tableone{'1/1/2005'} > $tabletwo{'1/1/2005'} etc...) Advantage here is that I would only have to poll the sql table five times. Downside is that I would be storing a lot of information in the hash structure and I'm not sure what the max available space is.
I would appreciate any commentary on which of the two methodologies is better / more efficient or if there is a way of going about this that I have not thought of.
Thanks.
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.