우노
[MongoDB] Index 본문
현재 컬렉션에 적용된 인덱스 확인하기
db.zipcodes.getIndexes()
Index 만들기
db.zipcodes.createIndex( { pop : 1 } )
속도 비교하기
// index가 돼 있으면 pop이 있는 도큐먼트만 본다! db.zipcodes.find({pop:100}).explain("executionStats") // 모든 도큐먼트 확인 -> pop이 있는 도큐먼트 찾기 -> 정렬 db.zipcodes.find({pop:100}).explain("executionStats")
Compound Index
여러개의 키를 가지고 인덱스를 만드는 것
db.zipcodes.createIndex( { city : 1, pop : 1} )
Index 지우기
key or Value로 삭제 가능!
db.zipcodes.dropIndex( "pop_1" )
'Database > MongoDB' 카테고리의 다른 글
[MongoDB] Aggregation (0) | 2020.07.03 |
---|---|
[MongoDB] mongoimport (0) | 2020.07.03 |
[MongoDB] Delete Collection (0) | 2020.07.02 |
[MongoDB] Delete Database (0) | 2020.07.02 |
[MongoDB] Create User (0) | 2020.07.02 |
Comments