You're actually exactly right however the database server is not have any issues executing this large query. In fact it is one of the fastest queries that runs on my server with the optimization that is done. I found that it is less efficient to loop through hundreds of queries one by one, opposed to running one large query filled with joins.
I'm now parsing the XML with a simple regexp and it uses less than half the memory when using the XML:Records module.
Thank you for everyones help, but it appears going back to the basics have solved my memory issues for the time being.