I interpret this scenario to be a volume of water perfectly insulated from all external temperature change that does not radiate any of its thermal energy. The removed water is uniformly heated to 90 degrees, which then perfectly distributes to the entire pool once returned.
Answering this question requires a unit of energy to serve as a medium for the computation. Let us call this unit the "liter-degree", which represents 1 degree Celsius per liter of water. (It's conceivable that there's a name for this already, but I don't know what it is off the top of my head. (Kilo-)Calorie comes close, but that's defined per kilogram). The pool starts with some number of liter-degrees, and it will end with some higher number of liter-degrees. Each time some of the water is removed, heated and returned, the net effect is that the full volume of water receives some increase in total number of liter-degrees, thereby uniformly raising its temperature.
The energy contents in liter-degrees of some volume of water will be the amount of water in liters multiplied by its temperature in degrees Celsius.
- How many liter-degrees does the pool start with, and how many will the pool have once fully heated to the target temperature?
- How many liter-degrees are added to the pool each time a portion of the water is removed, heated, then returned?
Once you know by how much the temperature increases each remove-heat-return cycle and how much the temperature needs to increase total, it will be trivial to determine how many times the remove-heat-return cycle is needed.
__________
EDIT:
It occurs to me that this isn't a simple division problem, because the temperature of the water being removed each time is slightly higher than it was the previous time. The number of liter-degrees being added each cycle is therefore less each time you do it (the water you remove keeps getting closer to 90 degrees each time you take out 500 L).
This is ostensibly a calculus question, but with discrete intervals. I regrettably don't have a lot of experience in this area, so I don't know that I could put together a formula without simulating it.