-
MongoDB findOne() without _id & MongoDB에서 find와 aggregate 성능 차이스터디노트/DB 2023. 1. 26. 09:39
findOne()으로 조회 시 _id 제외하기
const collection = 'yourCollection'; const result = await collection.findOne( { 조건, }, { projection: { _id: 0 } } );
find와 aggregate 성능차이
- Sharding 되지 않은 MongoDB 서버에서는 find와 aggregate 성능 차이가 없다고 한다.
- find 쿼리나 복잡한 aggregate 쿼리 모두 단일 Shard에서 실행되고 결과를 클라이언트에 전송한다.
참고자료
- findOne() without _id : https://stackoverflow.com/questions/48294613/mongo-find-function-wont-exclude-id
- 몽고디비 샤딩 : https://dailytaeho.tistory.com/31
- find vs aggregate : https://stackoverflow.com/questions/28364319/mongodb-aggregation-match-vs-find-speed
'스터디노트 > DB' 카테고리의 다른 글
How to push or pull item from an array in Mongoose (0) 2022.12.06 Mongodb add key-value pair to object (0) 2022.11.08 MongoDB Query for documents array size is greater than (0) 2022.09.20 필드가 배열인 경우 MongoDB update하기 (0) 2022.07.26 MongoDB 사칙연산 쿼리 (0) 2022.07.04