目前是1台16核64G的读写服务器,两台16核64G只读的服务器,想问问是否支持500万以上的数据查询。不卡顿,怎么把TDSQL-C MySQL 版 如何优化参数配置,提高性能?
在MongoDB 3.0及更高版本中,您必须运行一个命令来列出数据库中的所有集合:
use test;
db.runCommand( { listCollections: 1 } );
在MongoDB 3.0之前,您需要执行以下操作:
您可以查询system.namespaces
:
use test;
db.system.namespace.find( { name: 'test.' + collName } );
如:
db.system.namespaces.find( { name: 'test.testCollection' } );
返回:
{ "name" : "test.testCollection", "options" : { "flags" : 1 } }
另见:https://github.com/mongodb/specifications/blob/master/source/enumerate-collections.rst
collectionNames
本地驱动程序的方法Db
对象接受可选集合名称筛选器作为第一个参数,以检查集合是否存在:
db.collectionNames(collName, function(err, names) {
console.log('Exists: ', names.length > 0);
});
在MongoDB本机驱动程序的2.x版本中,collectionNames
已被listCollections
它接受一个过滤器并返回一个游标,因此您可以这样做:
db.listCollections({name: collName})
.next(function(err, collinfo) {
if (collinfo) {
// The collection exists
}
});