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.7b2.tar.gz (136.4 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.7b2-cp313-cp313-win_amd64.whl (7.2 MB view details)

Uploaded CPython 3.13Windows x86-64

xlr8-0.1.7b2-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.7b2-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.7b2-cp313-cp313-macosx_11_0_arm64.whl (7.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

xlr8-0.1.7b2-cp312-cp312-win_amd64.whl (7.2 MB view details)

Uploaded CPython 3.12Windows x86-64

xlr8-0.1.7b2-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.7b2-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.7b2-cp312-cp312-macosx_11_0_arm64.whl (7.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

xlr8-0.1.7b2-cp311-cp311-win_amd64.whl (7.2 MB view details)

Uploaded CPython 3.11Windows x86-64

xlr8-0.1.7b2-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.7b2-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.7b2-cp311-cp311-macosx_11_0_arm64.whl (7.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

xlr8-0.1.7b2-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.7b2.tar.gz.

File metadata

  • Download URL: xlr8-0.1.7b2.tar.gz
  • Upload date:
  • Size: 136.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xlr8-0.1.7b2.tar.gz
Algorithm Hash digest
SHA256 264b87eb842a3157590d490c1d45481363c281a942b206ed95e61f1e261545ab
MD5 99eff25d0bcf3080fb26c5d55e3b654b
BLAKE2b-256 0961705ab4b629b0e5e82101b7632c13e57e7e3006b1da162e59960d770c2513

See more details on using hashes here.

File details

Details for the file xlr8-0.1.7b2-cp313-cp313-win_amd64.whl.

File metadata

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

File hashes

Hashes for xlr8-0.1.7b2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 445baa3b05ab6c35cf9661745b9a51dc1a1f25a4748ba4413b8d7f4404376b52
MD5 55d8403d7095b15a3f2d415ebbd35d54
BLAKE2b-256 15ea12c10f94ef06a5e294300a1bd5cd289b7528e6e2a2c16250ee1de03cca44

See more details on using hashes here.

File details

Details for the file xlr8-0.1.7b2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.7b2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1f41bcd92b9132e0de7e5b89c1ea41d2d2543e5b67f47304bff841cf5dac4d28
MD5 797bd2e2fc07381f762d43fdd04743d0
BLAKE2b-256 b6a9e4a362aebb962b29b2500dfdeec5416044309814c715a1c627af9dfc8179

See more details on using hashes here.

File details

Details for the file xlr8-0.1.7b2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.7b2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1bd4321f20a4cb97f71e4c1a6bf014901fc6b8f31d3a58d0f9179a0e1c4191fe
MD5 ddb887e7bbdf1c92a11d93a9f64044e6
BLAKE2b-256 06cf89913bf25a9f83e6318309a870b029b68eb7f2e7799c9355b2bd17491b5d

See more details on using hashes here.

File details

Details for the file xlr8-0.1.7b2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.7b2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eee87abe3a44e2c3fb2384ae64ade31f1b2517118501f9c4723b4975718754d3
MD5 12fab059cc4a11cd2a477196f3efda66
BLAKE2b-256 56cb4d885d0c5462ed109fb2ff8b92a978295045da46d290b03f620029b692f7

See more details on using hashes here.

File details

Details for the file xlr8-0.1.7b2-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.7b2-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d3720f9ebd51be9e0d05992661ccf084670e33a02dfe3350e00ddd665bd047a1
MD5 ec5a78ad56dcc63b62e7b10ba69a5f39
BLAKE2b-256 24a74ad3b9fc960087c1ba400e77c26ec412748161648d5de97ecfa00a422f94

See more details on using hashes here.

File details

Details for the file xlr8-0.1.7b2-cp312-cp312-win_amd64.whl.

File metadata

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

File hashes

Hashes for xlr8-0.1.7b2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 379215a60ad7897ffb9f58a8f1aacd1b2e61211ccda143f412ed8a30a36dd630
MD5 24e3622668420e6b20b963d28b099df6
BLAKE2b-256 04f4318aa640107f70fedcf98bbb9863655d3abc7dbd39842f7cab67dc0ab44a

See more details on using hashes here.

File details

Details for the file xlr8-0.1.7b2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.7b2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cf8c5546e08a96a86f8c37ee224f65d93a66ade570fbb8522b10f24b7d8bb429
MD5 6c973cd4e25e815c63d73e028534a4a0
BLAKE2b-256 1cc65dbcdf41c9c2580cabed05f161c392e7e9bdc68ab5fdb0bca4a8f39a8bb0

See more details on using hashes here.

File details

Details for the file xlr8-0.1.7b2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.7b2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 15e810e2206e575f27390f1fd6531c16ca07ccb5e41753f605145aeb79c03f61
MD5 b6f518dd8fbbec1b105730050ff80b3a
BLAKE2b-256 9c608ecebeaef74ea5bd407671f46472ed7f04d543a57ab4459d92158a96ebf9

See more details on using hashes here.

File details

Details for the file xlr8-0.1.7b2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.7b2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3b976a81b81031382f136fabc3297b0d0fb687875798a653f7eba49b0657d662
MD5 00bae4a212f3527409487e023c6c14f4
BLAKE2b-256 4af407a7dbc231d21c0eaa005b525e8f21237721ab5d6c772d59a150c27e6c0c

See more details on using hashes here.

File details

Details for the file xlr8-0.1.7b2-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.7b2-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d12837201f9f10c4136e0b7b53de70849e87aaa8180bfd14329be388a6a51ae9
MD5 e7a496e2adcafa864ea6ec2ffb24e6d2
BLAKE2b-256 de527d362bce4081b3a02d5c87a2f2148dc1e086b554c0e8bce7dde4ca8e5c14

See more details on using hashes here.

File details

Details for the file xlr8-0.1.7b2-cp311-cp311-win_amd64.whl.

File metadata

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

File hashes

Hashes for xlr8-0.1.7b2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c9de4997ac3066a20f18ac615c5295db217bb906a3cb061070df05a27d4af962
MD5 b7e14c1ca4af212b43a34ac9c1b76bec
BLAKE2b-256 44713fa2fe6b8f626556d0800cbf2a02afcacbd921719752e0d11ebf6a59b955

See more details on using hashes here.

File details

Details for the file xlr8-0.1.7b2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.7b2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6074449b150ec06bc298ff4ef9563c03ae1fd1210d824c751f2ccc94f27bae61
MD5 0e1bc9e2fe77ab3ab7bdf80eca92497a
BLAKE2b-256 0b8524d579cb24602fe85205aaa361d33efb680394abdd6a20ad3111e8e6af11

See more details on using hashes here.

File details

Details for the file xlr8-0.1.7b2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.7b2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c9ccc1b6dfbc215d8afeb77f6444295e4ac7cf1680187f45c59676eae79ae12e
MD5 d2c7d8e857016c451a7d64763425ef95
BLAKE2b-256 fa9944a81a1d845a20f7846f55bf3058e0071f78d38b2422438e890ffb8b53af

See more details on using hashes here.

File details

Details for the file xlr8-0.1.7b2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.7b2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f18ac6f487057b10d0a7a75b49a51a12b7f470254c33829352347609430fed92
MD5 7ff9973e67ef7fce0d74e6729d1ae2af
BLAKE2b-256 a9f6f274c25011e283d376e4c3ade10184bd3cf05b2256e88d68decf88614281

See more details on using hashes here.

File details

Details for the file xlr8-0.1.7b2-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for xlr8-0.1.7b2-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 935b119101ddfc0553937f3aa4a18f6c5b25b38bd3da0c20eb6439e635ddbc61
MD5 5a2303e5ced9a30f79970fcf8955a76e
BLAKE2b-256 f6a2bf0c286dfc74b36f35ac8c767a2f3155562307bfd196171d01cbe2c1f6ff

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