On May 24, 9:24 am, Nate Wiger <[email protected]> wrote:
> Good point about database defaults.
>
> Stepping back for a second, what I'm really wondering is why new/save
> is so much slower than insert/find. Here's a trivial 
> benchmark:http://gist.github.com/412084
>
> The results are somewhat surprising:
>
> $ ./create_vs_insert
>                                     user     system      total
> real
> plain insert                    1.640000   0.250000   1.890000
> (  2.508927)
> find by id                      1.630000   0.260000   1.890000
> (  2.880001)
> create                          9.420000   1.080000  10.500000
> ( 13.431826)
> plain insert with find          3.420000   0.520000   3.940000
> (  5.634394)
>
> So it looks like Sequel is spending alot of time somewhere in new/save/
> create vs insert/find.  There are no validations or callbacks or
> anything on these models which could explain the difference.  Any
> ideas?

create is wrapping the insert/select in a database transaction,
whereas you aren't using one when inserting and selecting separately.
Also, even if you are not defining any validations or callbacks,
create is still calling the empty methods, and that's not free.    You
could profile if you want more details about where time is actually
spent.

I'm guessing most of the difference is in the use of transactions,
which can be modified using the use_transactions flag.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" 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/sequel-talk?hl=en.

Reply via email to