Hi Jeremy,

I'm glad the post actually went through! When I posted last night, there 
was no feedback after submitting it (or I missed it) and I didn't see the 
post listed afterwards.

The test is very simple and basic, nothing fancy. The test is designed so 
both AR and Sequel will retrieve the same number of records from the db. I 
didn't test your suggestion today, but I remember trying it and getting 
similar result. (I did some due diligence.)

The test scripts are on Github. The test of interest to you is here 
<https://github.com/hmistry/ar_sql/blob/master/sq/bench.rb#L63>. Looking at 
the memory reports, a large number of objects created are related to time 
(ruby-2.4.2/lib/ruby/2.4.0/time.rb:367). It's the biggest "offender" 
in where(), find(), and first() queries but probably necessary.

Regards,
Hiren.


On Tuesday, December 12, 2017 at 10:39:17 AM UTC-8, Jeremy Evans wrote:
>
> On Tuesday, December 12, 2017 at 9:26:00 AM UTC-8, Hiren Mistry wrote:
>>
>> Hi Jeremy,
>>
>> I ran some benchmarks recently to evaluate Sequel vs AR. Everything was 
>> in favor of Sequel except for one query which makes me think maybe 
>> something is wrong. I thought I'd bring it to your attention in case there 
>> may be a possible regression for that query. Or maybe I didn't implement it 
>> correctly. 
>>
>
> It's hard to determine why Sequel performs worse as you did not provide 
> the full code you used for the benchmark. If you post the code you used for 
> the benchmark, I'll look into why Sequel performs the way it does.
>
> The benchmark does show that Sequel creates a lot more garbage but retains 
> significantly less, so if I had to guess it is related to that.  My guess 
> is there is a very small number of objects returned by the query, so the 
> performance difference is due to the query building, not the retrieval. 
> Sequel's support for where(association_name: model_obj) is quite involved 
> in terms of code compared to ActiveRecord, mostly because of the much wider 
> support in Sequel compared to ActiveRecord when using associations in 
> queries.  Sequel supports all association types, considers most association 
> options such as conditions, supports composite keys, etc..  ActiveRecord I 
> believe just does a simple conversion of the association name to foreign 
> key name and model instance to primary key value. You could see if the 
> performance is significantly different with where(topic_id: topic.id).  
> All of this is mostly a guess on my part until I can see the code used.
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to