问题
I import an old database (hyperfile) to mysql to create a newapp with Laravel.
I'm using Laravel built in paginate method, but the first query "select count(*)" takes about 10 seconds to answer because there's about 70000 lines in this table.
I don't really need to know how many pages are present...just two buttons "previous/next" should be enough. Is there a method to avoid this query ?
回答1:
https://laravel.com/docs/5.2/pagination
"Simple Pagination"
If you only need to display simple "Next" and "Previous" links in your pagination view, you have the option of using the
simplePaginate
method to perform a more efficient query. This is very useful for large datasets if you do not need to display a link for each page number when rendering your view:$users = DB::table('users')->simplePaginate(15);
来源:https://stackoverflow.com/questions/37729226/laravel-disable-the-select-count-on-load-when-using-paginate-method