One of our project is using MongoDb and our database => collections are sharded. BTW, our collection gets created dynamically and hence we had to write a code inside our Application layer written in PHP to inform MongoDb to shard the collections. Hence I am looking for two options:
- Is there any way to identify if the collection is shareded via PHP? [or]
- Is there any problem in telling MongoDb to shard a collection which is sharded?
1] you can identify whether the collection is sharded or not by manipulating string output given by
db.printShardingStatus()check this to know how to print output of MongoDB
2] No issue to ask MongoDB to shard a collection which is already sharded.
Mongo wil never set “ok” to 1 if it is already sharded.
db.runCommand({ enablesharding : "sharded_db_name" })
{ "ok" : 0, "errmsg" : "already enabled" }