you get each guild's:
total prestige (the amount that shows on the leaderboard)
GVG prestige (adding up every prestige amounts for the guilds on each GVG map's map leaderboard, including the bonus for being 1st/2nd/3rd)
prestige bonus (the amount that shows on the level tab of their guild description, which is based on their level, so, you could instead save the prestige bonus for each level somewhere, and then join to it from a dataset that contains the guild's level)
Then their MMR, or what will be called League Points, is:
(total prestige - GVG prestige - prestige bonus) / 18
In terms of how you might do that efficiently .. that I can't help with, because if you don't know how to do it, nothing I have would be of much value.