On 6 March 2012 23:27, rubix Rubix
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> Hi,
>
> I am realizing my first application in Rails (with tutorials), I
> implement a pagination solution with will_paginate gem, it works well
> but the problem is: changing pages is very slow and I think the query is
> executed every time the page is changing
> Is there a solution to get faster pagination
> I am thinking about redis, is there a way to use it with will_paginate
>
> the query : User.find(:all,:order => "name")
When using paginate you should not be finding all records, only the
ones you need for the page. Does your tutorial cover this? I would
have expected it to be something like
@users = User.paginate :page => params[:page], :per_page => 10, :order
=> ''name''
However unless you have thousands of users I would not have expected
this to be an issue. If you are running in development mode you can
look in development.log to see how long the queries take.
If you are sorting on name you should probably have a database index
on that field, but again unless you have many users I would not have
expected to see a problem.
If you are running in development mode then you can expect it to be
slower than in production because it will load all the files at each
request, in production they are cached. The reason for this is so
that in development mode you do not need to restart the server if you
change a file.
Colin
> (I am using mysql)
>
>
> regards,
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
>
--
gplus.to/clanlaw
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.