Version Compatibility
The following table lists the minimum supported driver and MongoDB Server version for each compression algorithm:
Enable Network Compression
To enable network compression for your MongoDB connection, build the C driver with the required dependencies and specify the compression algorithms that you want to use.
Install Dependencies
The following table lists each algorithm and the dependency it requires, if any:
Specify Compression Algorithms
You can enable compression for the connection to your MongoDB instance by specifying the algorithms in one of the following ways:
Add the
compressorsparameter to your connection stringSet the compressors on a
mongoc_uri_tstruct
Select the Connection String or URI Option tab to view an example that specifies all available compressors:
Zlib Compression Level
When you use the Zlib algorithm, you can specify a compression level from -1 to 9. Lower levels generally provide faster compression with a lower compression ratio, and higher levels provide slower compression with a higher compression ratio.
Select the Connection String or URI Option tab to view an example that specifies a compression level for the zlib compressor:
API Documentation
For more information about the types and functions used on this page, see the following API documentation: