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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

File metadata

  • Download URL: xlr8-0.1.7b1.tar.gz
  • Upload date:
  • Size: 138.8 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.7b1.tar.gz
Algorithm Hash digest
SHA256 f17db8d49a89d4d272030a0ef0691ebb5b6bc41c8802c6c4bc07a745634a8550
MD5 5e3c6f99005b5b00f003e96f224419d8
BLAKE2b-256 20c512dd18357ae67353f3a48a5e1dbfac137c72cd542a767f73ae7eaa0d65e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlr8-0.1.7b1-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.7b1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 bf7ce820ebd6e3438a271ede599207884a0241d26b0622f8ea9ee688e3b5d361
MD5 5342ff34efa69274bc80282656a83ca5
BLAKE2b-256 82ea7262f456c2ad045dd9fdcb9a5378413f87d06e71f4b4872ee26274e2ea58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 51b5f2e805033820486a707cd088b5aafc03ba04e34f8eadda7062ed4c95c58f
MD5 c89713ae7b22f70c878c61fcc5151d63
BLAKE2b-256 087e0c7f87eeebc5526455eddf0c62480383065774fbc1f44292aa3615ec8de6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6a40f9d4b237b37134a57702f7746834d73fe6ee839c076e365bf960cd73e633
MD5 c83c8715048e63bf6fe62e45ed65bed4
BLAKE2b-256 a47a318a233996b9eebf45344cde6ba689ac7a058bacc16be94ff229d131839e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ce8db8bb0f37d3985edca2d25d85d8880ae695f38ba48d0f9fac8130527b8a42
MD5 3de11f5ea70ed4fc99a0d790c05dee01
BLAKE2b-256 f3fa7a1c6e00bbea350b6238853026f1220620bf85e02b3811d7d787c35e4cdf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b1-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 59da7be1cea4c8ee8449a8136faf8144684b3c0aa555a6e525b6324f199d46a2
MD5 443c16b08038eddc1b29092885ee65b4
BLAKE2b-256 bf8419cb3eac6ad3063924e37affd159b1e689e760859f61138436fbb21eb8e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlr8-0.1.7b1-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.7b1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 debf5d5e731ff87ab9e1728ea13db08fe64fc1f2c9128bb3756dc367234e8ea0
MD5 0d2d2e689c53275ba727da10db24ffce
BLAKE2b-256 37f452d88dae21ffeb7428327c3f81a285f22163940cf44735f23499ffeb9d77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c5a269251a3ccb951c352363b6442cf3f98dd3ab59a94b0482dc543ef5abf604
MD5 d707b1d398e06710656af868ed15dab3
BLAKE2b-256 83f1e5bac65b2f9c16f1df9f0752e41f3ed09a3eba4c560571b73386cd488e5c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7368b22320ea0811380f2e58f40ae95d6681cb2d24bfa097c17fcb691efa2bd4
MD5 baaad5e52f1299352a1c830481d5b920
BLAKE2b-256 eecf755115ad21dbaccb65f0a7e5dc408743b483bbfcbfc01fb3c200edf90904

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b0b4aca0ad458addc9132ba82dce8d3e660e2bf0e5032864ccd09b44a28d07f
MD5 6a24c24ad0326b8808ae67399637ec99
BLAKE2b-256 2281099ff73a5880475aeb7d99c6026ec73b0bd99f74fe077eefe399ce73975a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2c85bc5e8afef572c242488897e2f45c95080be290cfa89dbcb78c8d984520ed
MD5 a57c0029259581c2b3c97c3a3530be63
BLAKE2b-256 f6ee70eaba94b9fdad52be933ee32825ec7f447c698570b862c1390d340a7cfd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlr8-0.1.7b1-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.7b1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3e11e1c8dca304e93f36f0b4b038b6c5b810a267445fc190488dda57fac7eea6
MD5 93845fdf9f3d95ccc76672bf371da009
BLAKE2b-256 095fc966b0b9765b91b0644f2dde0f99c96cf82813170c71fc3bdcbd74381f85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d34f4aa0001452345d64302f061108b89f8ffd2f12041bdb51a2b71fd08cb733
MD5 54a30ae6f4824d57ec205ce659ed29c5
BLAKE2b-256 0a39be071fbffbb86106673793c966d7d0458a4aaa05ad8e47df23c124521eb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c9837adcb6b908546114870ed0eea9940cebfa875262ae61b1ab1ac8a325a5e5
MD5 663fe7e6f1563702282ea8478fffd73b
BLAKE2b-256 585ca4e6c5ec09b0d3ebf6057b8b38b35bb970619d15c0d956ecaae7a43a6b5c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e7c420429e7465fd9b4e9e418721da82d95757fcbcc0bac9dcf704e76a18a8d2
MD5 aed0cd0bcd90b65b9b3597327e612264
BLAKE2b-256 d10b5362fca4311a73bc84a9e6ced647429784c044b4e7896587e991ddb698f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 09d482a42377cb024f45cf39d84177d764eb8d1a4d78938b00a219e2990dc6c5
MD5 df9e88705c152372dd595bbd34b063c0
BLAKE2b-256 834db99ae3a60fbfea75c8728ceb67db26e3b563a9133bf8bad956ce657ff2bd

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