# Compression

By default the driver does not use any compression on connections.<br />
\\\\
It’s possible to specify a preferred compression algorithm. <br />
\\\\
The driver will try using it, but if the database doesn’t support it, it will fall back to no compression.

Available compression algorithms:

* Snappy
* LZ4

An example enabling `Snappy` compression algorithm:

```rust
use scylla::client::session::Session;
use scylla::client::session_builder::SessionBuilder;
use scylla::client::Compression;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let uri = std::env::var("SCYLLA_URI")
        .unwrap_or_else(|_| "172.42.0.2:9042".to_string());

    let session: Session = SessionBuilder::new()
        .known_node(uri)
        .compression(Some(Compression::Snappy))
        .build()
        .await?;

    Ok(())
}
```
