Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Improve Model::all()->first() #158

Open
Jud opened this issue Apr 12, 2016 · 0 comments
Open

Improve Model::all()->first() #158

Jud opened this issue Apr 12, 2016 · 0 comments

Comments

@Jud
Copy link
Collaborator

Jud commented Apr 12, 2016

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)?

Same applies to ::all()->last().

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant