我有一个 PHP 应用程序,我使用 Laravel 框架。当我开发应用程序时,它的响应时间不是问题。但是,当我部署它并且它在数据库中的一个事务表(此时几乎有 7,000 行)中获取大量数据时,刷新页面需要将近 6 秒。我只从数据库中获取最后 100 个数据以作为日志查看。有没有这样的方法来缩短这个响应时间?顺便说一句,我的应用程序仅在本地网络中运行。
这是我的代码:
Route::get('/', function()
{
$users = DB::table('logs')
->join('students', 'logs.id', '=', 'students.id')
->orderBy('time_in', 'desc')
->take(100)
->get();
return View::make('index')
->with('users',$users);
});