Thursday, March 13, 2014

MongoDB interview questions

  1. What kind of datastore is MongoDB?
    MongoDB is a document-oriented NoSQL datastore
  2. Which format are the documents stored in MongoDB?
    Documents are stored in binary form of JSON known as BSON
  3. How can you inspect a source code of a function?
    The function must be invoked without any parentheses
  4. Which language is supported by MongoDB for UDF?
    Both built-in functions and UDFs are written in JavaScript
  5. What are the different type of indexes supported by MongoDB?
    B-Tree index and GeoSpatial index
  6. How is a index created?
    An index is created by calling ensureIndex(fields,options)
  7. How will you see the explain plan for a query?
    By calling the explain() function.  For example, db.book.find().explain()
  8. How will you find if you are on the master server?
    Db.isMaster()
  9. How many master does MongoDB allow?
    Only one.  CouchDB allows multiple masters.
  10. What is the ObjectId composed of?
    The ObjectId is composed of timestamp, client machine id, client process id, 3 byte incremented counter
  11. Can documents stored in MongoDB collection vary in structure?
    Since MongoDB documents are schemaless they can very in structure
  12. What is the command syntax for inserting a document?
    database.collection.insert(document)
  13. From which node are the reads performed by default?
    From the primary node by default.
  14. Are transactions supported?
    No, classical operations such as insert, update, delete, commit, rollback are not supported
  15. What is master or primary?
    A master or primary node in a replica set is where all write operations take place.  In the event of primary node failure other node (member) may be elected as primary.
  16. What is a secondary or slave?
    A secondary or slave is a node/member which is replicated from actions of primary.  The actions are replicated to a slave from primary in an asynchronous fashion.  The slave will try to stay as close to the primary as possible.
  17. Why are data files so large in MongoDB?
    In order to avoid filesystem fragmentation, MongoDB employs agressive preallocation of reserved space.
  18. How can I see the connection used by mongos?
    db._adminCommand("connPoolStats")
  19. What feature I can use to do safe hot backups?
    Journaling
  20. What is the role of profiler in MongoDB?
    The profiler shows the performance characteristics of each operation against the database.

No comments:

Post a Comment