On 18 July 2017 at 14:53, <www.ezhubb.com@gmail.com> wrote:
> hi,
>
> when i run my index action it takes forever to load up
> (www.ezhubb.com/search). how
> can i speed up the mysql / rails process?
>
> i do try to limit the results, but this code is not working:
> @q = MyModel.order("RAND()").limit(100).ransack(:some_field => Date.today )
> @q.result(distinct: true).includes(:user).paginate(page: params[:page],
> per_page: 30) #.order("RAND()")
I am not an expert on this but I suspect that MyModel.order("RAND()")
may be horrendously slow on a table with a large number of rows. You
could see if this is the issue by removing the order clause to see if
it makes a big difference.
Colin
>
>
> any ideas how to speed this up? ho wmany record should i pull when no search
> criterias
> are given? everything is still on default settings (mysql, nginx etc..)
>
> thx
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/dc4958a3-838f-40ef-8708-2d59cf26a120%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLuEUd--BO%2B9sbNgNVhDPJT8XSE6YC9L7F6x7GtZdqUQ9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment