Before doing something like this you might want to check the index structre on your database. I know this isn't really a Perl answer, but with larger data sets, such a massive scoop and throw into memory may not be a really good answer. Checking or creating an index on the key fields might be a better alternative, and more useful in the long run.