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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

File metadata

  • Download URL: xlr8-0.1.7.tar.gz
  • Upload date:
  • Size: 138.6 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.7.tar.gz
Algorithm Hash digest
SHA256 0aa04f6b518af738e4629a12a3b9f6c397f473ed1113ed13efadd06f1350df27
MD5 79787fa17c0852ff51f23fecdec2cfce
BLAKE2b-256 9a38e910cdd40c3740674fe2ce4f8719bcde7e8c8c0acb07138db299f92815be

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlr8-0.1.7-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.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 46155882e7245e26ad9e24c65391ffd7541f6f088db164d5dc6c067409511f02
MD5 3a4e5e92b4599cb1d51b650a787cdde2
BLAKE2b-256 251749676c80c1a45b5964b7c873b5153f0a5fb61d3bbf8ab585a651e35836dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fd4378546c2fa647b8801b59e9e53a180fa57931ab230f4e00ef8a7563766286
MD5 fdc4a011bac12ab68650267149606351
BLAKE2b-256 c653e04cfd3e31d93007e27d6c2ca1f3998583618cd63c7697aeec141a550bae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 59bea7f2afb0e8d1851f0dde4a538d33dcd11275da715997fa3a698b61d65a02
MD5 a0a35c0168017cf924ae0bd4f57c4d02
BLAKE2b-256 49f57eeff659b94df2a00321079f9205d8cc4db19f0ce12e4ed273961f0e6939

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f7efaec4d85f404c0ae92f7ee276de91823c46afd63c94a7c697057248d61b41
MD5 3f4e637289ab6fa5935f902b8bc6425e
BLAKE2b-256 ac33981fad2960ad41c5747f0a3b4b7417048a5dbccd35bcd4c71b642c95db22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 01f45ca2f08a12cf379e3767944fc291a49f77df412c9090457cb7b260eac520
MD5 604d914366fbc5f58e8a416b00fe7c22
BLAKE2b-256 d9408ac105649f11fc84e4984869eeee03398fcfb506a0369f434611dfd7dbe4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlr8-0.1.7-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.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9a9409a949731540ee5e1874aff968ba8c9935b619c50e3141925cd069dc9c46
MD5 cb4de7fe10ffc3c3b522ea070dba1a2f
BLAKE2b-256 6e4b8374a9a2818273cfceff59a7dc0ad61dd981dcd793d50057c98eda9bdf64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0961ed6167f5e0412e316d4b9c7cf268aa68f5eb2b4d861261e9e9fb58221314
MD5 efc9c2afe622b44f9510579c9c74816f
BLAKE2b-256 9ff19a4ff4cc1ae96c0b3c5b12df53a981aa6b08fac063cb309764f803599fc4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2018f8048871af4194c290ccbf34fb34691f80ed7545118e271938ec499aea88
MD5 8ea1de22e0d83efced990ba75f50690e
BLAKE2b-256 f1fc4106980d504420a28ef5e6d94821ee10cdc73bb3c00a197bcb9c5ad14041

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8367f4dc273e86a043ced00261724739e6a1fab108e9902db834a7d8812c84a3
MD5 25a5368e229e691fff7955378316a041
BLAKE2b-256 3edce667ff92e0cdbda3005fe1288f0c304610797c409dcda2ac64fd4f149460

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7fd6eb5d678feb1a317d05da2545cd9530eda1a9271f9308bdeafb5182b04b95
MD5 7706a70260a32ebbed07189c11feb992
BLAKE2b-256 25bf48056bd67148ca587334e8683b0697340b1c055be3be196f361877878d5a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlr8-0.1.7-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.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 610ea7c52fabb18b03c2de95fdb6858d52a4f5e831b4683017481001b56b11b6
MD5 9727ff1595ba2284cc1986253061fb48
BLAKE2b-256 fc932b68feb1de3eda3a2944f70e39beba150c6eade26595207ab15f9a0ec92d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 46cd3f6ef510df374daf4e57bbb721f7c302304011a9428b389978d3f3ff4c27
MD5 4dd0fc218d269dd2f04ec6a69f4b9893
BLAKE2b-256 6e324223fc46c550f0b436488b9bd44a7bb5cfe702d2e87de7e29accf8f74efa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7d49551f0cb301a981f3b92734de40034813881de73c51f44ce7451fcd292458
MD5 f7d5d9790681a1ab16080061580bf53b
BLAKE2b-256 d49f169f8dda8e7e354be7a9c2d13d30edfa95c1aaba1876630b3d2cd5a41e57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8e7682855b38d7355a743b59ed0042df9fe52033128ca16bec713ca1a30ddea2
MD5 467629a60e0d7ce5db69ceb154e93986
BLAKE2b-256 24cdefd44adf82e849a67d63b7dd9241152a9aa7993b638b5a5b5f5bb73731d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d572ff8125bb5a4643deef4c83dc3a108c42c4f93a869be7039a727a348a4a33
MD5 6f32443f183f029745871eaf32045f08
BLAKE2b-256 175c8d4d4e78c46d562d90d1a06f82b58aba2e7bdc3eacfca22f19728c29ba6a

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