We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
hi. method exists() in yii\mongodb\Query by default has not projection or limit in command. so MongoDB return all document and field in result.
exists()
yii\mongodb\Query
User::Find()->Where(['_id' => oid('5de3320034af172d38e38102')])->Exists() #yii2 output: find({"ns":"myDB.users","filter":{"_id":"MongoDB\\BSON\\ObjectId(5de3320034af172d38e38102)"}})
vs
User::Find()->Select(['_id'])->Limit(1)->Where(['_id' => oid('5de3320034af172d38e38102')])->Exists() #yii2 output: find({"ns":"myDB.users","filter":{"_id":"MongoDB\\BSON\\ObjectId(5de3320034af172d38e38102)"},"limit":1,"projection":{"_id":true}})
please see Benchmarking findOne() vs. find()->limit(1)->count(true)
The text was updated successfully, but these errors were encountered:
We can likely add LIMIT 1 to exists by default.
Sorry, something went wrong.
@ziaratban want to try making a pull request?
better performance for exists() method of Query class
8b1efe5
yiisoft#290
8fbf600
No branches or pull requests
hi.
method
exists()
inyii\mongodb\Query
by default has not projection or limit in command. so MongoDB return all document and field in result.vs
please see Benchmarking findOne() vs. find()->limit(1)->count(true)
The text was updated successfully, but these errors were encountered: