On Tuesday, October 1, 2013 2:16:00 AM UTC-7, Edward J wrote:

> Hi,
>
> Is it possible to accomplish a similar result as when you use a limited 
> association in postgres with mysql
>
> for example:
>
> I have a association set up as
> one_to_many :recent_comments, :class => :Comment, :order => :date, :limit 
> => 5
>
> if I run Article[123].recent_comments it works as expected but if i want 
> to fetch multiple articles and eagely fetch this association it ignores the 
> limit.
>
> Article.eager(:recent_comments).limit(10).all
> just runs 
>
> SELECT * FROM `comments` WHERE (`comments`.`article_id` IN (1, 2, 3 ....)) 
> ORDER BY `date`
>
> I know mysql doesn't support the partition by syntax, but is there another 
> way around this to limit eager fetching of associations?
>

Sequel used to support a correlated_subquery eager limit strategy, but it 
was removed in 4.0 as it wasn't very portable, and in some cases could 
cause even worse performance.  Note that Sequel still returns the correct 
results in this case, since it does array slicing in ruby.

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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to