Query your database using iterators and save memory