I'm not sure how much of a speed-up you'll get by foregoing DateTime
fields. I think most of the slow down happens in the overhead of
instantiating complex model objects for every single row returned.
That said, you *could* declare those DateTime properties as type
String, and DM will not bother to cast the property into DateTime
objects; it wouldn't be safe to write, but it should be okay for read-
only.

Alternatively, you could also query the datastore directly, e.g.:

    DataMapper.repository.adapter.select("SELECT id, name,
initial_timestamp FROM  package_records WHERE initial_timestamp >= ?",
2.months.ago)

The #select call will return an Array of Structs, and
initial_timestamp should be a String.

Just curious though: if a straight MySQL call completes the process in
an order of magnitude faster and if performance is important on this
specific case, why not skip DM entirely?


On Jul 27, 2:14 am, Randy Fischer <[email protected]> wrote:
> Networthy,
>
> I have an application that's running too slow using DM
> and am wondering what I can do to speed it up.  Originally I
> was using straight MySQL or Postgres, processing 15,000
> records in a few seconds to produce an XML file.
>
> Using a naive datamapper implementation, it's taking
> several minutes.
>
> I simplified my model to one table to do some simplified
> benchmarks, DM produces on the order 3,400 records/sec;
> straight MySQL  is closer to 65,000 records/sec.
>
> That simplified model can be seen at
>
>    http://gist.github.com/491815
>
> I have two columns that are DateTime fields in my model, and
> while straight MySQL in ruby reads them as strings, DM of
> course casts them to DateTime objects - I've convinced
> myself that's cause for the time difference.
>
> I do need them as DateTime types in the underlying database
> for other, non-ruby applications.   In fact, I'd like them to be
> cast to DateTime ruby objects most of the time, just not this
> one.
>
> Are there any tricks for speeding this up?  A way to get DM
> to change it's casting from the underlying DateTime  in the
> database to simple strings when required?
>
> Thanks for any insight you can provide.
>
> -Randy Fischer

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to