YouTube Icon

Interview Questions.

Top 30 MongoDB Interview Questions 2019 - Jul 16, 2022

fluid

Top 30 MongoDB Interview Questions 2019

Q1. What is MongoDB?

Ans: Mongo-DB is a record database which offers advanced, high accessibility and simple adaptability.

Q2. What are the nice capabilities of Mongodb?

Ans:

Document-orientated

High overall performance

High availability

Easy scalability

Rich-question language

Q3. What is a duplicate set?

Ans: A copy set is a group of mongo examples that host comparable statistics index. In replica set, one hub is vital, and any other is auxiliary. From crucial to the secondary hub all information replicates.

Q4. How replication works in MongoDB?

Ans: Over distinct servers, the way towards synchronizing information is known as replication. It offers extra and increment information accessibility with diverse duplicates of statistics on numerous database servers. Replication helps in protective the database from the departure of a solitary server.

Q5. What is “Namespace” in MongoDB?

Ans: MongoDB stores BSON (Binary Interchange and Structure Object Notation) gadgets within the series. The hyperlink of the gathering name and database call is called a namespace.

Q6. What is sharding in MongoDB?

Ans: The machine of storing records records over distinctive machines is known as Sharding. It is a MongoDB manner to address the requests of information development. It is the flat section of records in a database or search engine. Each partition is referred as shard or database shard.

Q7. How can you see the relationship utilized by Mongos?

Ans: To see the association used by Mongos utilize db_adminCommand (“connPoolStats”);

Q8. Does an update fsync to disk straight away?

Ans: No. Writes to disk are lazy through default. A write may additionally only hit the disk a couple of seconds later. For instance, if the database receives thousand increments to an object inside one second, it will only be flushed to disk once. (Note: fsync options are available each at the command line and via getLastError_old.)

Q9. How do I do transactions/locking?

Ans: MongoDB does not use conventional locking or complicated transactions with rollback, as it is designed to be light weight, rapid and predictable in its overall performance. It may be notion of the way analogous is to the MySQL’s MyISAM autocommit version. By keeping transaction aid extraordinarily simple, performance is more suitable, specifically in a system that could run throughout many servers.

Q10. Why are facts documents so huge?

Ans: MongoDB does competitive preallocation of reserved space to avoid report device fragmentation.

Q11. When the use of replication, can some members use journaling and others now not?

Ans: Yes!

Q12. Can journaling feature be used to perform safe hot backups?

Ans: Yes!

Q13. What is 32-bit nuances?

Ans: There is an additional reminiscence mapped document pastime with journaling. This will similarly constrain the restrained db size of 32-bit builds. For now, journaling by default is disabled on 32-bit systems.

Q14. Will there be journal replay packages in case of incomplete entries (if there is a failure inside the middle of 1)?

Ans: Each magazine (organization) write is constant and received’t be replayed all through healing unless it's far complete.

Q15. Are null values allowed?

Ans: Yes, but best for the contributors of an object. A null cannot be brought to the database series because it isn’t an item. But may be delivered.

Q16. Is it required to name ‘getLastError’ to make a write long lasting?

Ans: No. If ‘getLastError’ (aka ‘Safe Mode’) isn't called, the server does precisely behave the manner as if it has been called. The ‘getLastError’ name in reality lets in one to get a confirmation that the write operation changed into efficiently committed. Of path, often you will need that confirmation, however the safety of the write and its sturdiness is independent.

Q17. Should you start out with Sharded or with a Non-Sharded MongoDB surroundings?

Ans: We advocate starting with Non-Sharded for simplicity and brief startup, except your initial facts set will not match on single servers. Upgrading to Sharded from Non-sharded is straightforward and seamless, so there isn't always a variety of gain in putting in place Sharding before your facts set is big.

Q18. What is the position of profiler in MongoDB?

Ans: MongoDB includes a database profiler which indicates overall performance traits of every operation towards the database. With this profiler you may find queries (and write operations) which can be slower than they need to be and use this information for figuring out whilst an index is needed.

Q19. When an item characteristic is removed, is it deleted from the store?

Ans: Yes, you can do away with the characteristic after which re-keep() the object.

Q20. How lengthy does replica set failover take?

Ans: It may additionally take 10-30 seconds for the number one to be declared down by the alternative members and a new number one to be elected. During this window of time, the cluster is down for primary operations i.E writes and sturdy regular reads. However, eventually constant queries may be done to secondaries at any time (in slaveOk mode), which includes at some stage in this window.

Q21. What’s a Master or Primary?

Ans: This is a node/member that's currently the number one and techniques all writes for the reproduction set. During a failover occasion in a duplicate set, a distinct member can grow to be number one.

Q22. What’s a Secondary or Slave?

Ans: A secondary is a node/member which applies operations from the cutting-edge number one. This is finished with the aid of tailing the replication oplog (neighborhood.Oplog.Rs). Replication from primary to secondary is asynchronous, but, the secondary will attempt to stay as close to cutting-edge as viable (regularly this is only some milliseconds on a LAN).

Q23. How does Sharding paintings with replication?

Ans: Each Shard is a logical series of partitioned facts. The shard could encompass a single server or a cluster of replicas. Using a reproduction set for each Shard is fantastically recommended.

Q24. When will statistics be on a couple of Shard?

Ans: MongoDB Sharding is variety-primarily based. So all of the gadgets in a group lie into a chunk. Only while there is more than 1 bite there's an alternative for a couple of Shards to get data. Right now, the default chew size is 64mb, so you want as a minimum 64mb for migration.

Q25. What takes place when a document is up to date on a bit this is being migrated?

Ans: The update will undergo right now at the antique Shard and then the exchange might be replicated to the brand new Shard earlier than ownership transfers.

Q26. What takes place whilst a Shard is down or gradual while querying?

Ans: If a Shard is down, the question will return an blunders until the ‘Partial’ query options is ready. If a shard is responding slowly, Mongos will anticipate it.

Q27. Can the vintage files in the ‘moveChunk’ listing be removed?

Ans: Yes, those files are made as backups in the course of regular Shard balancing operations. Once the operations are accomplished then they can be deleted. The clean-up system is currently guide so this needs to be sorted to loose up space.

Q28. How do you notice the connections utilized by Mongos?

Ans: The following command desires to be used: db._adminCommand(“connPoolStats”);

Q29. What are the negative aspects of MongoDB?

Ans:

A 32-bit version has 2GB statistics limit. After that it'll corrupt the complete DB, along with the prevailing data. A 64-bit version gained’t be afflicted by this worm/feature.

Default set up of MongoDB has asynchronous and batch commits grew to become on. Meaning, it lies when asked to shop something in DB and commits all modifications in a batch at a later time in destiny. If there may be a server crash or energy failure, all the ones commits buffered in reminiscence could be lost. This functionality can be disabled, however then it will perform as precise as or worse than MySQL.

MongoDB is handiest ideal for imposing things like analytics/caching wherein effect of small facts loss is negligible.

In MongoDB, it’s difficult to symbolize relationships among statistics so you end up doing that manually by way of developing every other desk to represent the connection between rows in two or more tables.

Q30. Mention how you may inspect the supply code of a function?

Ans: To look at a source code of a function, with none parentheses, the function have to be invoked.




CFG