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

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

@Jud

Description

@Jud

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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions