yiisoft / yii2-mongodb

Yii 2 MongoDB extension
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
326 stars 191 forks source link

better performance for exists() method of Query class #298

Open ziaratban opened 4 years ago

ziaratban commented 4 years ago
Q A
Is bugfix? yes
New feature? no
Breaks BC? no
Tests pass? yes
Fixed issues #290
ziaratban commented 4 years ago

@samdark what is milestone for this PR ?

samdark commented 4 years ago

2.1.10. Overall it looks extremely hacky. Need @yiisoft/core-developers and @yiisoft/reviewers opinions about it.

schmunk42 commented 4 years ago

Some more explanation why this is better would be nice. Did you benchmark this?

Also test do not pass.

samdark commented 4 years ago

@schmunk42 the explanation is in https://github.com/yiisoft/yii2-mongodb/issues/290

schmunk42 commented 4 years ago

How about

public function exists($db = null, $optimized = false)

and do the modifications when $optimized is true.

samdark commented 4 years ago

@schmunk42 does it make sense to do it in non-optimized way?

schmunk42 commented 4 years ago

@schmunk42 does it make sense to do it in non-optimized way?

I am no mongo expert, my concern is only about BC.

Counterquestion: Why is it not done by mongo, if it makes no difference?

ziaratban commented 4 years ago

@schmunk42 does it make sense to do it in non-optimized way?

@samdark please see Checking if a document exists – MongoDB slow findOne vs find

samdark commented 4 years ago

The link could be added to comment since the code there causes questions immediately.