# Leanest way to query with the results in a typed hash?

**URL:** <https://www.ruby-forum.com/t/leanest-way-to-query-with-the-results-in-a-typed-hash/122277>\
**Category:** Rails\
**Created:** [December 6, 2007, 4:19am UTC](https://www.ruby-forum.com/t/leanest-way-to-query-with-the-results-in-a-typed-hash/122277 "2007-12-06T04:19:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![magpie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/45deac/32.png) [@magpie](https://www.ruby-forum.com/u/magpie)\
**Post date:** [December 6, 2007, 4:19am UTC](https://www.ruby-forum.com/t/leanest-way-to-query-with-the-results-in-a-typed-hash/122277/1 "2007-12-06T04:19:59Z")

</div>

I’m querying many thousands of rows in a table, and would like the  
result to be a hash with the values in the correct types eg. Time,  
String, Fixnum.  
I’d rather not use the normal find() as that creates model objects with  
all their memory requirements. Is there a simple solution, or should I  
put something together from the Rails source ?

Regards,

magpie

---

<div class="post-metadata">

**Author:** ![magpie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/45deac/32.png) [@magpie](https://www.ruby-forum.com/u/magpie)\
**Post date:** [December 6, 2007, 11:01am UTC](https://www.ruby-forum.com/t/leanest-way-to-query-with-the-results-in-a-typed-hash/122277/2 "2007-12-06T11:01:24Z")

</div>

On 6 Dec 2007, at 03:19, Mr Magpie wrote:

> I’m querying many thousands of rows in a table, and would like the  
> result to be a hash with the values in the correct types eg. Time,  
> String, Fixnum.  
> I’d rather not use the normal find() as that creates model objects  
> with  
> all their memory requirements. Is there a simple solution, or should I  
> put something together from the Rails source ?

ActiveRecord::Base.connection.select\_all ‘select \* from foos’  
Will give you an array of hashes, but the values will all be strings

Fred
