[TIL] 0328
Today I Learnt
0328:
몽고 db자채에있는 aggregate와 mongoose 의populate함수 비교
https://stackoverflow.com/questions/55575806/mongoose-populate-vs-aggregate
Mongoose populate vs aggregate
I've noticed that .populate function in mongoose 4.7.3 runs separate queries on the database for each lookup: db.House .populate('ownerId') .exec((err, result) => { .. With aggre...
stackoverflow.com
Here's a summary of the differences:
$lookup
- can only be used with aggregate
- can only be used to pull in referenced documents from unsharded collections
- can pull in referenced documents by any field
- generally more performant as it's a server-side operation
- requires MongoDB 3.2+
Mongoose populate()
- can be used with find and aggregate
- can be used to to pull in referenced documents from both sharded and unsharded collections
- can only pull in referenced documents by _id
- no MongoDB version requirement
차이점은 이렇게 정리되었다고하지만 그럼 속도는 뭐가더빠를까?
https://medium.com/cameoeng/mongodb-lookups-and-populates-an-unexpected-journey-940e08e36a94
MongoDB Lookups and Populates: An Unexpected Journey
By Kunal Bhatt
medium.com
document가 20개미만일때만, look up이빠르고 아니면 populate가더빠름.
'MongoDB in Action'으로 정리해보는 MongoDB의 인덱스 개념
MongoDB in Action https://book.naver.com/bookdb/book_detail.nhn?bid=6876243 MongoDB in Action 몽고디비 인 액션 MONGODB나 NOSQL에 경험 없는 개발자를 위한 쉽고 실전적인 입문서『MONGODB IN ACTION 몽..
nangkyeong.tistory.com
짧지만 중요한 오늘! TIL 끝
'IT > TIL(Today I Learnt)' 카테고리의 다른 글
[TIL] 0404 - 0407 (4) | 2022.04.07 |
---|---|
[TIL] 0329 (2) | 2022.04.01 |
[TIL] 0325 프로삽질러 (5) | 2022.03.26 |
[TIL]0324 (0) | 2022.03.24 |
[TIL] 0323 세상에 믿을사람없다 (3) | 2022.03.23 |