Skip to content

Tweak to make sum() 2x faster :) #284

Open
@BenasPaulikas

Description

@BenasPaulikas

Hey so my recent discovery. Idk if this should be implemented in code somehow...

'x' attribute has index.

Model::find()->sum('x') - 700ms
Model::find()->where(['x' => ['$exists' => true]])->sum('x') - 300ms

sum() is doing aggregate()

"In order for an aggregation pipeline to "use" an index the $match stage must be implemented first."

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions