Skip to main content

High-performance database read acceleration layer for MongoDB. Auto-chunks and parallelizes queries across multiple-workers, streams results to parquet with intelligent caching and memory-bounded execution, option to stream data directly to any data lake. Same PyMongo API but dramatically faster results with RUST backend for CPU-heavy tasks.

Project description

XLR8 Logo

Accelerate MongoDB analytical queries with parallel execution and Parquet caching

Faster Queries → Less Memory → Real Savings

GitHub Python versions License

🦀 Rust-Backed · ⚡ Up to 4x Faster Queries · 📦 10-12x Compression · 📊 Configurable Memory Limits


Minimal Code Changes

# Before: PyMongo
df = pd.DataFrame(list(collection.find(query)))

# After: XLR8 - just wrap and go!
xlr8_collection = accelerate(collection, schema, mongodb_uri)
df = xlr8_collection.find(query).to_dataframe()

That's it. Same query syntax, same DataFrame output - just faster.


The Problem

When running analytical queries over large MongoDB collections, you encounter two fundamental bottlenecks:

I/O Bound: PyMongo uses a single cursor, fetching documents one batch at a time. Your CPU sits idle waiting for network round trips.

CPU/GIL Bound: Even with the data in hand, Python's Global Interpreter Lock (GIL) means BSON decoding and DataFrame construction happen on a single core.

These aren't PyMongo limitations - they're inherent to Python's design. XLR8 provides a solution.


How XLR8 Solves It

XLR8 releases Python's GIL and hands execution to a Rust backend powered by Tokio's async runtime:

  1. Query Planning → Splits your query into time-based chunks
  2. Parallel Workers → Multiple workers fetch from MongoDB simultaneously
  3. BSON → Arrow → Direct conversion without Python overhead
  4. Parquet Caching → Results cached for instant reuse
  5. DataFrame Assembly → Final merge via DuckDB (GIL-free)

The result? Your analytical queries run significantly faster, especially for large result sets.


Installation

pip install xlr8

XLR8 requires Python 3.11+ and includes pre-compiled Rust extensions for Linux, macOS, and Windows.


Quick Start

from pymongo import MongoClient
from xlr8 import accelerate, Schema, Types
from datetime import datetime, timezone, timedelta

# Connect to MongoDB
client = MongoClient("mongodb://localhost:27017")
collection = client["iot"]["sensor_readings"]

# Define your schema
schema = Schema(
    time_field="timestamp",
    fields={
        "timestamp": Types.Timestamp("ms", tz="UTC"),
        "device_id": Types.ObjectId(),
        "reading": Types.Any(),  # Handles int, float, string dynamically
    },
    avg_doc_size_bytes=200,
)

# Wrap collection with XLR8
xlr8_col = accelerate(collection, schema=schema, mongo_uri="mongodb://localhost:27017")

# Query like normal PyMongo
cursor = xlr8_col.find({
    "timestamp": {"$gte": datetime(2024, 1, 1, tzinfo=timezone.utc)}
}).sort("timestamp", 1)

# Get DataFrame - parallel fetch, cached for reuse
df = cursor.to_dataframe(
    chunking_granularity=timedelta(days=7),
    max_workers=8,
)

Key Features

Feature Description
🦀 GIL-Free Rust Backend Python's GIL is released. Rust's Tokio runtime handles async I/O across all cores.
Parallel MongoDB Fetching Queries split into time chunks. Each worker has its own MongoDB connection.
💾 Smart Query Cache Results cached by query hash. Filter cached data by date range.
🔀 DuckDB K-Way Merge GIL-free sorting across shards - O(N log K) complexity.
🐻‍❄️ Pandas & Polars to_dataframe() for pandas, to_polars() for Polars.
📊 Memory Control Set flush_ram_limit_mb to prevent OOM errors on large datasets.
📤 Stream to Data Lakes stream_to_callback() for S3/GCS ingestion pipelines.

Performance

Metric Improvement
Query Speed Up to 4x faster on large result sets
Compression 10-12x storage reduction with Parquet
Memory Configurable limits prevent OOM
Repeat Queries Instant from cache

Documentation

📖 Full documentation with architecture diagrams: GitHub Repository


License

Apache 2.0 - See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xlr8-0.1.10.tar.gz (163.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

xlr8-0.1.10-cp313-cp313-win_amd64.whl (7.3 MB view details)

Uploaded CPython 3.13Windows x86-64

xlr8-0.1.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

xlr8-0.1.10-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

xlr8-0.1.10-cp313-cp313-macosx_11_0_arm64.whl (7.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

xlr8-0.1.10-cp313-cp313-macosx_10_12_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

xlr8-0.1.10-cp312-cp312-win_amd64.whl (7.3 MB view details)

Uploaded CPython 3.12Windows x86-64

xlr8-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

xlr8-0.1.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

xlr8-0.1.10-cp312-cp312-macosx_11_0_arm64.whl (7.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

xlr8-0.1.10-cp312-cp312-macosx_10_12_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

xlr8-0.1.10-cp311-cp311-win_amd64.whl (7.3 MB view details)

Uploaded CPython 3.11Windows x86-64

xlr8-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

xlr8-0.1.10-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

xlr8-0.1.10-cp311-cp311-macosx_11_0_arm64.whl (7.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

xlr8-0.1.10-cp311-cp311-macosx_10_12_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

File details

Details for the file xlr8-0.1.10.tar.gz.

File metadata

  • Download URL: xlr8-0.1.10.tar.gz
  • Upload date:
  • Size: 163.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xlr8-0.1.10.tar.gz
Algorithm Hash digest
SHA256 60fb853c9a0d6f3727b5b438426219d0bd4c35e733318c5c6f179f282fb034f8
MD5 a6e600ac122009bfdc1a070dd3d9b4c1
BLAKE2b-256 46368d2531904db80663ecf05d76e109985d2f2d46fac5c687c668b8921ef82f

See more details on using hashes here.

File details

Details for the file xlr8-0.1.10-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: xlr8-0.1.10-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 7.3 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xlr8-0.1.10-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 fee94fda84fb5c615a7b63b05a7cd3463df1cc603fbd1c7a054d4c054569692f
MD5 f5a4cd0309d2335eb96616c234ccc5da
BLAKE2b-256 ced043f8d9ddcdb7f671b84946c2904100013abf8e43cddc16848a0a1f9ff7c2

See more details on using hashes here.

File details

Details for the file xlr8-0.1.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a1bc69017d38177a95e762fcdbcfbfd156f8eec510cdbdaa24157caba38f641a
MD5 554d86bbb1a65d711bc61dc227427da6
BLAKE2b-256 2e78f18126cd22c28207c39417848d96ef440303154b1cc5a9e9b6608be83ae1

See more details on using hashes here.

File details

Details for the file xlr8-0.1.10-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.10-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c43f2093cfe11be5256e39e12fbe2e4470878bee3a8c00f2536a538ee16a5499
MD5 5510e8e9866cb96fcc30f7d0ab36d40e
BLAKE2b-256 a5879b99bd2c5e84be16c862f6a9f3537b2857bd49ca9cbe255c623e14490b44

See more details on using hashes here.

File details

Details for the file xlr8-0.1.10-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.10-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cc2385e257eebdf530b990d4fa850bb831725f89ccb9d3913b4958b3839a4156
MD5 d6bc59063ad5d320c9414811293b3303
BLAKE2b-256 3646d16b69555327ea6d576e6dd0e2b06090b5da17558cd677802d98f8da800a

See more details on using hashes here.

File details

Details for the file xlr8-0.1.10-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.10-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5a97da8ee4085b417c364adbff93ef901ae66ae071d2513b19a2ab253264cd24
MD5 1cd76575f4ba46b233861907855a02f2
BLAKE2b-256 8301538454848c75ab8e5b7153b9b2ee4ce095fdee0b005091b4c48a73921f35

See more details on using hashes here.

File details

Details for the file xlr8-0.1.10-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: xlr8-0.1.10-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 7.3 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xlr8-0.1.10-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 bb5658b827a3595cce2323884533da6e8af0ba4d3e7d223f64617599ffc4f543
MD5 e5342904922b83ccaaf1898920d5f1b2
BLAKE2b-256 6e9d641f39a546aafa2366690043eea0e2864aea96d54cdc2a90240a3d2f28fe

See more details on using hashes here.

File details

Details for the file xlr8-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ebf0a2d5acf3762aaa95852071f40211beff583e47172ef5816797e20d41e3fc
MD5 59f4e04ab2d5985fc9e3b721e706722a
BLAKE2b-256 bad77fe868b7dbfca9d4bcfec660722b9e627f130391acb03f96a018cf5c15bf

See more details on using hashes here.

File details

Details for the file xlr8-0.1.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 467667d010bf5eea717e9f75dca7fcec205a5b00799716f279ad0c3abea0c514
MD5 b83dec0dafe562b2c8b031e8f0f409dc
BLAKE2b-256 5964adb641ed2d9e96ce88bb419f68e158a89c5b733ec57e61272769ac01166a

See more details on using hashes here.

File details

Details for the file xlr8-0.1.10-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2263bf6a15002228544b9b134a2e4966d30cf7e819133ae3f8e0fc441d544b02
MD5 19160c13a86e8ec7689aded25b214eb6
BLAKE2b-256 ced56eaaacc3f6a8aad321c5711a12d8d6480f9d9dd735d7bf91aae31f973513

See more details on using hashes here.

File details

Details for the file xlr8-0.1.10-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.10-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f2d1f73a11c81002cfee46d449e32c877441c7c63383477495006e2d02d18113
MD5 abc5b62bd40b4069350d5ef438be56c4
BLAKE2b-256 c7735fed3dbf63ceed61aa04d1065510570bcb5122848bb5fd521cf0e6de6d3f

See more details on using hashes here.

File details

Details for the file xlr8-0.1.10-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: xlr8-0.1.10-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 7.3 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xlr8-0.1.10-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5e1aaa051f3d29ca443f6a36c08d2f0569d8f08ff953cdd5df2ab178001f7615
MD5 1dcb0f58b73e7a09d019ef310f9d0546
BLAKE2b-256 eb1260fc9951663364d2aafd22dc778336a57c33aebaa8c08c09ae7a7b1887d6

See more details on using hashes here.

File details

Details for the file xlr8-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 50f8ea19b1a63b1cc7c70f440987ea632d72ebd6c403ad4122fe7489958b9c01
MD5 0500a5fee003bfb857bd7ac273d5181b
BLAKE2b-256 cc065bb78d83a994c0dacb0e9beeb63b6bdc8ea8f7a6788574942c7413c84066

See more details on using hashes here.

File details

Details for the file xlr8-0.1.10-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.10-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 324d8dbc76ce4c0b2c2f9302bf38f09de2ee124bd58e8e6dfe4f019793639686
MD5 43ed295d7d500cdfc232fa6196e61952
BLAKE2b-256 8b7462d1b4c0773856f27564f379fc0716a5bcb9fdf538390f24991e8b08351c

See more details on using hashes here.

File details

Details for the file xlr8-0.1.10-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.10-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e2f37266df87fe5997282bac1a9a5bcd5fc1606e760ff8a083c407effa4e8feb
MD5 29ee90cec659849efdf477870e258557
BLAKE2b-256 989098b274a9c7c5290ab8854b664e2c0d8ded2f7afdf30e6c8765e851d36a8b

See more details on using hashes here.

File details

Details for the file xlr8-0.1.10-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.10-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ca1bd37fa3eceb0702070055d1a68c0cc69d67f10864d1d7d0a559f1f8056823
MD5 854cfcbe049c9b5876d2f090b4af0316
BLAKE2b-256 85e407df9c87e5d9805239dfde95060b6a08ea908a80c64988ce9c7f081c5367

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page