Thanks THRAK. Sorry about the lack of code example. I'm doing what you suspect -> looping over a fetch from the statement handle and putting the data in a hash array. I had a feeling I might have to break this up into smaller queries.
Big queries are fine.
However, if you're doing this, check out perltie.
This should cure many evils associated with hash sizes taking you out of memory.