I had User::all()->first() in some test code, and I was a bit surprised when it ran out of memory when run against the staging database. Looks like the generated sql is something like SELECT User.* FROM users as User, which creates an object for each row before selecting the first one.
Would anyone have an issue with a PR to make ::all()->first() work identical to ::all()->orderBy('primaryKey asc')->limit(1)?
I had
User::all()->first()
in some test code, and I was a bit surprised when it ran out of memory when run against the staging database. Looks like the generated sql is something likeSELECT User.* FROM users as User
, which creates an object for each row before selecting the first one.Would anyone have an issue with a PR to make
::all()->first()
work identical to::all()->orderBy('primaryKey asc')->limit(1)
?Same applies to
::all()->last()
.