-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PYTHON-3930 Add docs page for network compression (#1415)
- Loading branch information
1 parent
4b9c5b9
commit a09a03e
Showing
5 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
.. _network-compression-example: | ||
|
||
Network Compression | ||
=================== | ||
|
||
PyMongo supports network compression where network traffic between the client | ||
and MongoDB server are compressed which reduces the amount of data passed | ||
over the network. By default no compression is used. | ||
|
||
The driver supports the following algorithms: | ||
|
||
- `snappy <https://pypi.org/project/python-snappy>`_ available in MongoDB 3.4 and later. | ||
- :mod:`zlib` available in MongoDB 3.6 and later. | ||
- `zstandard <https://pypi.org/project/zstandard/>`_ available in MongoDB 4.2 and later. | ||
|
||
.. note:: snappy and zstandard compression require additional dependencies. See :ref:`optional-deps`. | ||
|
||
Applications can enable wire protocol compression via the ``compressors`` URI and | ||
keyword argument to :meth:`~pymongo.mongo_client.MongoClient`. For example:: | ||
|
||
>>> client = MongoClient(compressors='zlib') | ||
|
||
When multiple compression algorithms are given, the driver selects the first one in the | ||
list supported by the MongoDB instance to which it is connected. For example:: | ||
|
||
>>> client = MongoClient(compressors='snappy,zstandard,zlib') | ||
|
||
The ``compressors`` option can also be set via the URI:: | ||
|
||
>>> client = MongoClient('mongodb://example.com/?compressors=snappy,zstandard,zlib') | ||
|
||
Additionally, zlib compression allows specifying a compression level with supported values from -1 to 9:: | ||
|
||
>>> client = MongoClient(compressors='zlib', zlibCompressionLevel=-1) | ||
|
||
The ``zlibCompressionLevel`` is passed as the ``level`` argument to :func:`zlib.compress`. | ||
|
||
.. seealso:: The MongoDB documentation on `network compression URI options <https://dochub.mongodb.org/core/compression-options>`_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters