Lets learn to create index and to optimize the database in MongoDB. Creating "Database": "temp", "Collection": "no", and inserting 10…