MongoDB - DDL Operations and Indexing

Now let us understand some of the key aspects related to DDL as well as Indexing.

  • Creating and Dropping Collections
  • Adding and Dropping Indexes
    • We can speed up adding data to denormalized collection orderDetails if we have index on order_item_order_id in orderItems.
  • Adding Indexes will slow down write operations, but speeds up read operation.
  • _id is automatically indexed, we can create secondary indexes using createIndex over the collection.
  • We can also drop indexes using functions such as dropIndex