1MONGOC_DATA_COMPRESSION(3)         libmongoc        MONGOC_DATA_COMPRESSION(3)
2
3
4
5The  following  guide  explains how data compression support works between the
6MongoDB server and client. It also shows an example of how  to  connect  to  a
7server with data compression.
8

COMPRESSING DATA TO AND FROM MONGODB

10       MongoDB  3.4  added  Snappy compression support, while zlib compression
11       was added in 3.6, and zstd compression in 4.2.  To  enable  compression
12       support the client must be configured with which compressors to use:
13
14          mongoc_client_t *client = NULL;
15          client = mongoc_client_new ("mongodb://localhost:27017/?compressors=snappy,zlib,zstd");
16
17       The  compressors option specifies the priority order of compressors the
18       client wants to use. Messages are compressed if the client  and  server
19       share any compressors in common.
20
21       Note  that the compressor used by the server might not be the same com‐
22       pressor as the client used.  For example, if the client uses  the  con‐
23       nection  string  compressors=zlib,snappy  the client will use zlib com‐
24       pression to send data (if possible), but the server might  still  reply
25       using snappy, depending on how the server was configured.
26
27       The driver must be built with zlib and/or snappy and/or zstd support to
28       enable compression support, any unknown (or not compiled in) compressor
29       value will be ignored.
30

AUTHOR

32       MongoDB, Inc
33
35       2017-present, MongoDB, Inc
36
37
38
39
401.25.1                           Nov 08, 2023       MONGOC_DATA_COMPRESSION(3)
Impressum