- 전체
- Sample DB
- database modeling
- [표준 SQL] Standard SQL
- G-SQL
- 10-Min
- ORACLE
- MS SQLserver
- MySQL
- SQLite
- postgreSQL
- 데이터아키텍처전문가 - 국가공인자격
- 데이터 분석 전문가 [ADP]
- [국가공인] SQL 개발자/전문가
- NoSQL
- hadoop
- hadoop eco system
- big data (빅데이터)
- stat(통계) R 언어
- XML DB & XQuery
- spark
- DataBase Tool
- 데이터분석 & 데이터사이언스
- Engineer Quality Management
- [기계학습] machine learning
- 데이터 수집 및 전처리
- 국가기술자격 빅데이터분석기사
- 암호화폐 (비트코인, cryptocurrency, bitcoin)
ORACLE [몽고디비 mongodb] 몽고디비에서 벌크 오퍼려이션과 배열 삽입의 차이점은 what is the difference between bulk insert and array insert in Mongo db operations
2020.10.09 22:01
[몽고디비 mongodb] 몽고디비에서 벌크 오퍼려이션과 배열 삽입의 차이점은
what is the difference between bulk insert and array insert in Mongo db operations
Questuion [질문] =================================================
I am wondering how following queries varies in performance. I understand that bulk insert executes in sequence and normal/array inserts also executes in sequence.
BULK INSERT
var bulk = db.items.initializeUnorderedBulkOp();
bulk.insert( { _id: 1, item: "abc123", status: "A", soldQty: 5000 } );
bulk.insert( { _id: 2, item: "abc456", status: "A", soldQty: 150 } );
bulk.insert( { _id: 3, item: "abc789", status: "P", soldQty: 0 } );
bulk.execute( { w: "majority", wtimeout: 5000 } );
Normal INSERT
db.items.insert( { _id: 1, item: "abc123", status: "A", soldQty: 5000 } );
db.items.insert( { _id: 2, item: "abc456", status: "A", soldQty: 150 } );
db.items.insert( { _id: 3, item: "abc789", status: "P", soldQty: 0 } );
Array INSERT
var array_insert = [
{ _id: 1, item: "abc123", status: "A", soldQty: 5000 } ,
{ _id: 2, item: "abc456", status: "A", soldQty: 150 } ,
{ _id: 3, item: "abc789", status: "P", soldQty: 0 }
] ;
db.items.insert( array_insert );
Can any one explain what is the difference interms of performance or benefits for the above queries ?
Answer[답변] =============================================================
Bulk insert is faster because inserts are sent all at once. Compare it to the regular flow where you send one insert, wait for server reply and only then send next insert.
It takes server the same amount of work to insert all the things, regardless of the mode (bulk vs. regular). In regular mode time is lost on client while it waits for server to respond. Not necessarily because server is slow. Network may be slow too.
Batching requests is a common way of speeding up application, regardless of the database used. See, for example, pipelining in Redis.
[출처] https://stackoverrun.com/ko/q/8347056
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.