listtransactions loops through every transaction in your wallet, so it isn't very fast or scalable.
I could make the "listtransactions" loop scalable by using the "[count=10] [from=0]" parameters.
Right now I loop 50 entries at a time.
And if I see a transaction thats already in my database i stop the loop.
This will make my approach scalable.
But it will only work if all new incoming transactions are added to the top of the list.
Because if any new transaction is added before a known transaction, my approach will skip that transaction.