我有以下数据库表:-
id - PK (Auto Increment)
hash - a unique index the value here is filled using the function "uniqid()"
title - string..
我想使用哈希值而不是ID从表中查询。这种做法是否会加载服务器,因为我知道这是从DB表中获取某些行的最佳方法,特别是那些包含大量行的行正在使用主键进行搜索:-
$row = Book::find(1);
或者我可以使用以下雄辩的生成器,而不必担心对数据库服务器造成不必要的负载,因为他的哈希设置为唯一键:
$row = Book::where('hash',$hashFromAPiRequest)->first();
There is some package named laravel Scout , i am not sure if i really need to use it or not.