我在windows 10机器上使用MongoDB v4.2.7和.Net MongoDB驱动程序v2.11.0(beta v)。
var mongoClientSettings = new MongoClientSettings();
mongoClientSettings.Compressors = new List<CompressorConfiguration>() {
new CompressorConfiguration(CompressorType.ZStandard)
};
var client = new MongoClient(mongoClientSettings);
IMongoDatabase testdb = client.GetDatabase("testdb");
var eaiRequestLogsCollection = testdb.GetCollection<EAIRequestsLogMDB>("EAIRequestsLogs");
eaiRequestLogsCollection.InsertMany(eAIRequestsLogMDBs);我编辑了我的mongod.cfg文件如下:
storage:
dbPath: C:\Program Files\MongoDB\Server\4.2\data
journal:
enabled: true
engine: "wiredTiger"
wiredTiger:
collectionConfig:
blockCompressor: "zstd"在成功地添加了集合和文档之后,我在mongo上运行了db.printCollectionStats(),在WiredTiger部分获得了block_compressor=snappy,而它应该是block_compressor=zstd。
下面是db.Stats(1024*1024*1024)输出以及"dataSize“:0.08773485571146011和"storageSize”:0.009387969970703125的屏幕截图。
发布于 2020-06-10 07:24:00
我在MongoDB开发人员社区论坛上发布了一个问题,并被告知我的c#代码设置的是网络压缩而不是block_compressor。
这是对我有用的正确的c#代码:
var client = new MongoClient("mongodb://127.0.0.1:27017");
IMongoDatabase testdb = client.GetDatabase("testdb");
testdb.CreateCollection("EAIRequestsLogs", new CreateCollectionOptions()
{
StorageEngine = new BsonDocument
{
{ "wiredTiger", new BsonDocument
{
{ "configString" , "block_compressor=zstd"}
}
}
}
});
var eaiRequestLogsCollection = testdb.GetCollection<EAIRequestsLogMDB>("EAIRequestsLogs");致以亲切的问候。
https://stackoverflow.com/questions/62262314
复制相似问题