[eluser]danmontgomery[/eluser]
The solution is to write better queries so you're not getting back 24,000 results... Increasing memory allocation to account for this amount of data isn't a real solution, it's a band-aid, and you're inevitably going to have to do it again (and again).