[TIL] 0328

IT/TIL(Today I Learnt)|2022. 3. 29. 13:32

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가더빠름. 

 

 

https://nangkyeong.tistory.com/entry/MongoDB-in-Action%EC%9C%BC%EB%A1%9C-%EC%A0%95%EB%A6%AC%ED%95%B4%EB%B3%B4%EB%8A%94-MongoDB%EC%9D%98-%EC%9D%B8%EB%8D%B1%EC%8A%A4-%EA%B0%9C%EB%85%90

 

'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

댓글()