Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我的雄辩有什么解决办法吗?时间太长了_Php_Mysql_Laravel_Eloquent - Fatal编程技术网

Php 我的雄辩有什么解决办法吗?时间太长了

Php 我的雄辩有什么解决办法吗?时间太长了,php,mysql,laravel,eloquent,Php,Mysql,Laravel,Eloquent,我想从中获取第一个和最新的数据,但时间太长,因为表中有超过100k条记录。有什么解决办法吗?谢谢你 这是我的密码: $checkInOut = Fingerprint::where('USERID', 317)->where('CHECKTIME', '>=', $startDate)->where('CHECKTIME', '<=', $dayAfterStartDate)->get(); $checkIn = $checkInOut->first(); $

我想从中获取第一个和最新的数据,但时间太长,因为表中有超过100k条记录。有什么解决办法吗?谢谢你

这是我的密码:

$checkInOut = Fingerprint::where('USERID', 317)->where('CHECKTIME', '>=', $startDate)->where('CHECKTIME', '<=', $dayAfterStartDate)->get();
$checkIn = $checkInOut->first();
$checkOut = $checkInOut->last();`

$checkInOut=Fingerprint::where('USERID',317)->where('CHECKTIME','>=',$startDate)->where('CHECKTIME','p>覆盖
USERID
CHECKTIME
列上的索引将加快数据检索速度

CREATE INDEX idx_fingerprint ON Fingerprint(userid, checktime);

USERID
CHECKTIME
列上覆盖索引将加快数据检索速度

CREATE INDEX idx_fingerprint ON Fingerprint(userid, checktime);