I have a mysql table of 100+ curr ency values dating back some time giving some 30k+ rows.
Taking any particular curr ency combo:
1/ i loop through all rows selecting all the rows applicable to the 1st
2/ then within each loop select the 2nd’s value for that date
3/ calculate the combined value
4/ print out the value for the pair on each date.
Below is some sudo code to give principle:
select * from vals where c=1st order by dateset DESC
while....{
get $thisdateset
select * from vals where c=2nd and dateset=$thisdateset
while....{....
}
}
Problem is that this is taking over 9 seconds just this section of the code!
Trying to think of best approach here. Any ideas?
I have ruled out storing the combination values every day as this would mean 10k rows every day, plus would take ages to complete via cron daily.
I also thought about writing it all to a text file, but same applies really.