My application using rails '3.2.20', mysql2 '0.3.20' and will_paginate '3.0.7'
I'm trying to load user records
@users = User.paginate(:page => params[:page], :per_page => 20)
Below queries executed in console
User Load (0.3ms) SELECT `users`.* FROM `users` LIMIT 20 OFFSET 0
(0.3ms) SELECT COUNT(*) FROM `users`
Generally will_paginate run two queries for collections and count
But I got one more extra query when used page_entries_info in view
User Load (0.3ms) SELECT `users`.* FROM `users` LIMIT 20 OFFSET 0
(0.3ms) SELECT COUNT(*) FROM `users`
User Load (0.2ms) SELECT `users`.* FROM `users` LIMIT 1 OFFSET 0
hope last query is not used anywhere.
I just illustrate with simple example, but my application executes large query with more joins and includes.
It may slow down the performance with unnecessary query.
This occurs only after will_paginate '3.0.3'
is it bug/functionality? how to avoid this extra query?
Aucun commentaire:
Enregistrer un commentaire