MONGOC_DATA_COMPRESSION(3)
π MONGOC_DATA_COMPRESSION(3) π
okay bestie, welcome to the libmongoc guide on data compression π«Ά this is the one that explains how data compression support works between the MongoDB server and the client, and then shows you an actual example of how to connect to a server with data compression turned on. no cap, it's a short one, but it's important.
β¨ COMPRESSING DATA TO AND FROM MONGODB β¨
so here's the timeline, and it's giving evolution:
- MongoDB 3.4 added Snappy compression support πΈ
- MongoDB 3.6 brought zlib compression into the chat
- MongoDB 4.2 said "and also zstd" π
to enable compression support, the client has to be configured with which compressors to use, like this:
mongoc_client_t *client = NULL;
client = mongoc_client_new ("mongodb://localhost:27017/?compressors=snappy,zlib,zstd");
the compressors option specifies the priority order of compressors that the client wants to use. messages get compressed if the client and the server share any compressors in common. mutuals only, fr fr π€
heads up! the compressor the server ends up using might not be the same compressor the client used. like, not even a little. for example: if the client uses the connection string compressors=zlib,snappy, the client will use zlib compression to send data (if possible), but the server might still reply using snappy, depending on how the server was configured. it's their world and we're just living in it π
also important: the driver must be built with zlib and/or snappy and/or zstd support to enable compression support at all. and any unknown compressor value (or one that isn't compiled in) will just be ignored. silently. no drama, no error. periodt.
π AUTHOR
MongoDB, Inc
π COPYRIGHT
2017-present, MongoDB, Inc
and that's the whole page, bestie!! this was libmongoc 1.26.0, dated Mar 31, 2024 β go forth and compress responsibly πβ¨π¦
π¦ where this page comes from
- ubuntu noble: libmongoc-doc 1.26.0-1.1ubuntu2 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms