Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
BenasPaulikas opened this issue Sep 30, 2019 · 0 comments
Open

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

BenasPaulikas opened this issue Sep 30, 2019 · 0 comments
Labels
type:enhancement Enhancement

Comments

@BenasPaulikas
Copy link

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."

@samdark samdark added the type:enhancement Enhancement label Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement Enhancement
Projects
None yet
Development

No branches or pull requests

2 participants