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()")
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
This gem could help you rack-mini-profiler.
Cheers
looks promising - will try thx
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