Sort:  

Are you collecting from day 1 for each account? damn!

My pleasure!

Yes, I have to do this from day 1, otherwise, I would not know the current delegation amount. But, I'm planning to store the account history on disk, so that it will be faster.

Right :)

Yeah for those 2+ year old accounts that have been active throughout this time, that sounds like some serious number crunching. Good luck!