SlideShare a Scribd company logo
INDEXING
MONGODB INDEXING
•With the use of Indexes, performing queries in MongoDB becomes more efficient.
•MongoDB would use these indexes to limit the number of documents that had to be
searched in the collection.
•Indexes are special data sets which store a partial part of the collection's data. Since
the data is partial, it becomes easier to read this data.
UNDERSTANDING IMPACT OF INDEXES
• Having too many indexes can slow down other operations such as the Insert, Delete
and Update operation.
• If there are frequent insert, delete and update operations carried out on documents,
then the indexes would need to change that often, which would just be an overhead
for the collection.
• An index can either be based on just one field in the collection, or it can be based on
multiple fields in the collection.
EXAMPLE
HOW TO CREATE INDEXES: CREATEINDEX()
MongoDB - Indexing- Types  iNDEXING.pptx
MongoDB - Indexing- Types  iNDEXING.pptx
MongoDB - Indexing- Types  iNDEXING.pptx
MongoDB - Indexing- Types  iNDEXING.pptx
MongoDB - Indexing- Types  iNDEXING.pptx
MongoDB - Indexing- Types  iNDEXING.pptx
MongoDB - Indexing- Types  iNDEXING.pptx
MONGODB INDEX PROPERTIES
Unique Indexes
•This property of index causes MongoDB to reject duplicate values for the indexed
field.
• In other words, a unique property of indexes restricts it to insert the duplicate value
of an indexed field.
EXAMPLE
We create an index using createIndex() for the name field and set unique to be true.
Then insert a document with fields “name” and “city”.
MongoDB - Indexing- Types  iNDEXING.pptx
db.student.createIndex({name:1},{unique:true})
MongoDB - Indexing- Types  iNDEXING.pptx
PARTIAL INDEXES
•This property came in MongoDB version 3.2.
• Partial Indexes only index the documents that match the filter criteria.
•If we are creating an index with some conditions applied then it is a partial index.
MongoDB - Indexing- Types  iNDEXING.pptx
SPARSE INDEXES
•The sparse property ensures that the index only contains entries for documents with
the indexed field.
•The index will skip the documents without the indexed field.
•We can combine this option with the unique index option in order to reject documents
with duplicate values for a field.
•And can ignore documents without an indexed key at the same time.
> db.student.createIndex({name:1},{unique:true,sparese:true})
{
“createdCollectionAutomatically” : false,
“numIndexesBefore” : 2,
“numIndexesAfter” : 3,
“ok” : 1
}
>

More Related Content

PDF
Nosql part 2
Ruru Chowdhury
 
PPTX
Query Optimization in MongoDB
Hamoon Mohammadian Pour
 
DOCX
unit 4,Indexes in database.docx
RaviRajput416403
 
PPTX
Mongo db index
zarigatongy
 
PPT
Fast querying indexing for performance (4)
MongoDB
 
PPTX
Indexing Strategies to Help You Scale
MongoDB
 
PPTX
UNIT-1 MongoDB.pptx
DharaDarji5
 
PDF
Mongodb Introduction
Raghvendra Parashar
 
Nosql part 2
Ruru Chowdhury
 
Query Optimization in MongoDB
Hamoon Mohammadian Pour
 
unit 4,Indexes in database.docx
RaviRajput416403
 
Mongo db index
zarigatongy
 
Fast querying indexing for performance (4)
MongoDB
 
Indexing Strategies to Help You Scale
MongoDB
 
UNIT-1 MongoDB.pptx
DharaDarji5
 
Mongodb Introduction
Raghvendra Parashar
 

Similar to MongoDB - Indexing- Types iNDEXING.pptx (20)

ODP
Mongo indexes
paradokslabs
 
PPTX
MongoDB and Indexes - MUG Denver - 20160329
Douglas Duncan
 
PPTX
Mongo db
Gyanendra Yadav
 
PDF
3-Mongodb and Mapreduce Programming.pdf
MarianJRuben
 
PPTX
Top MongoDB interview Questions and Answers
jeetendra mandal
 
PPT
Mongo db tutorials
Anuj Jain
 
PPTX
MongoDB is a document database. It stores data in a type of JSON format calle...
amintafernandos
 
PPTX
Mongodb Performance
Jack
 
PDF
Mongo db a deep dive of mongodb indexes
Rajesh Kumar
 
PPTX
MongoDB - An Introduction
dinkar thakur
 
PPTX
MongoDB 2.4 and spring data
Jimmy Ray
 
PPTX
Types of indexing in MongoDB-Indexing.pptx
revathyvr4
 
PPTX
OVERVIEW OF MONGODB | CREATING USER IN MONGODB & ASSIGNING ROLES
IQ Online Training
 
PDF
Storage dei dati con MongoDB
Andrea Balducci
 
PPTX
Basics of MongoDB
HabileLabs
 
PDF
Quick overview on mongo db
Eman Mohamed
 
PPT
Introduction to MongoDB
Ravi Teja
 
PDF
Mongophilly indexing-2011-04-26
kreuter
 
KEY
2012 phoenix mug
Paul Pedersen
 
PPTX
Mongo DB
Tata Consultancy Services
 
Mongo indexes
paradokslabs
 
MongoDB and Indexes - MUG Denver - 20160329
Douglas Duncan
 
Mongo db
Gyanendra Yadav
 
3-Mongodb and Mapreduce Programming.pdf
MarianJRuben
 
Top MongoDB interview Questions and Answers
jeetendra mandal
 
Mongo db tutorials
Anuj Jain
 
MongoDB is a document database. It stores data in a type of JSON format calle...
amintafernandos
 
Mongodb Performance
Jack
 
Mongo db a deep dive of mongodb indexes
Rajesh Kumar
 
MongoDB - An Introduction
dinkar thakur
 
MongoDB 2.4 and spring data
Jimmy Ray
 
Types of indexing in MongoDB-Indexing.pptx
revathyvr4
 
OVERVIEW OF MONGODB | CREATING USER IN MONGODB & ASSIGNING ROLES
IQ Online Training
 
Storage dei dati con MongoDB
Andrea Balducci
 
Basics of MongoDB
HabileLabs
 
Quick overview on mongo db
Eman Mohamed
 
Introduction to MongoDB
Ravi Teja
 
Mongophilly indexing-2011-04-26
kreuter
 
2012 phoenix mug
Paul Pedersen
 
Ad

Recently uploaded (20)

PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PPTX
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
PPTX
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
PDF
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
PPTX
Presentation about variables and constant.pptx
safalsingh810
 
PDF
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
PDF
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
PDF
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
DOCX
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
PDF
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
PPTX
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
PPTX
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
Presentation about variables and constant.pptx
safalsingh810
 
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
Activate_Methodology_Summary presentatio
annapureddyn
 
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
Bandai Playdia The Book - David Glotz
BluePanther6
 
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
Presentation about variables and constant.pptx
kr2589474
 
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
Ad

MongoDB - Indexing- Types iNDEXING.pptx

  • 2. MONGODB INDEXING •With the use of Indexes, performing queries in MongoDB becomes more efficient. •MongoDB would use these indexes to limit the number of documents that had to be searched in the collection. •Indexes are special data sets which store a partial part of the collection's data. Since the data is partial, it becomes easier to read this data.
  • 3. UNDERSTANDING IMPACT OF INDEXES • Having too many indexes can slow down other operations such as the Insert, Delete and Update operation. • If there are frequent insert, delete and update operations carried out on documents, then the indexes would need to change that often, which would just be an overhead for the collection. • An index can either be based on just one field in the collection, or it can be based on multiple fields in the collection.
  • 5. HOW TO CREATE INDEXES: CREATEINDEX()
  • 13. MONGODB INDEX PROPERTIES Unique Indexes •This property of index causes MongoDB to reject duplicate values for the indexed field. • In other words, a unique property of indexes restricts it to insert the duplicate value of an indexed field.
  • 14. EXAMPLE We create an index using createIndex() for the name field and set unique to be true. Then insert a document with fields “name” and “city”.
  • 18. PARTIAL INDEXES •This property came in MongoDB version 3.2. • Partial Indexes only index the documents that match the filter criteria. •If we are creating an index with some conditions applied then it is a partial index.
  • 20. SPARSE INDEXES •The sparse property ensures that the index only contains entries for documents with the indexed field. •The index will skip the documents without the indexed field. •We can combine this option with the unique index option in order to reject documents with duplicate values for a field. •And can ignore documents without an indexed key at the same time.
  • 21. > db.student.createIndex({name:1},{unique:true,sparese:true}) { “createdCollectionAutomatically” : false, “numIndexesBefore” : 2, “numIndexesAfter” : 3, “ok” : 1 } >