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.9.tar.gz (141.5 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.9-cp313-cp313-win_amd64.whl (7.3 MB view details)

Uploaded CPython 3.13Windows x86-64

xlr8-0.1.9-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.9-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

xlr8-0.1.9-cp313-cp313-macosx_11_0_arm64.whl (7.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

xlr8-0.1.9-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.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

xlr8-0.1.9-cp312-cp312-macosx_11_0_arm64.whl (7.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11Windows x86-64

xlr8-0.1.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

xlr8-0.1.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

xlr8-0.1.9-cp311-cp311-macosx_11_0_arm64.whl (7.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

xlr8-0.1.9-cp311-cp311-macosx_10_12_x86_64.whl (7.8 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: xlr8-0.1.9.tar.gz
  • Upload date:
  • Size: 141.5 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.9.tar.gz
Algorithm Hash digest
SHA256 80a9d71676590136fc2030869525987e98bcd33936f616b025c9ccdb66706231
MD5 21a25d392121dc64b396f139cd45f266
BLAKE2b-256 83a75cfb927b6549cbc820bfa0a5fa18869332c40c742c359158153046da2705

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlr8-0.1.9-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.7

File hashes

Hashes for xlr8-0.1.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 54395414a8fae13006263055b1dbd499254d9181dba5d86e560bd516ec9c5b0b
MD5 48d54dcd7777cee634def91e5ff4e056
BLAKE2b-256 ade56b8039d29e6c6066cf1c23fbd519c9310911482a55294768cc8bf75fc0f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.9-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6ceec856e1a280464470a6de2948c84e5340658ca8449fb3fc1cffe9f61e1f62
MD5 3b43b8668c79fb898dc54c2921844b71
BLAKE2b-256 d89c48594d899edaa04c06151ffd051d3a55e17636a3f6d186fcd6b822365ed8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.9-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fc2500af75518d0ef06e948e527d63560e06b239d1647108f1e17189683b423c
MD5 6a2640a8a0ee716811f237dc6123e99c
BLAKE2b-256 bda624e5c13377dd723b74b79cb8827ebfbf52fc8b237962f6a4bcd8a21988c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.9-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 12ddbba2bd839a34d65e58f45c0a7309ac5352fb3d42c966010393e5a18ccf31
MD5 951219c88c91182073267b355e48bbb5
BLAKE2b-256 2e5f7f1e49dc8903d68c4538fa904cf45cb911dfb3b1e20cacbaeb339c0dbec1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.9-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c02d09b4cb3ee089f34765a28a5df04c2feabd5e534b5b83023c9eeb6c1e2b89
MD5 d0967dbdc49da80024d5312b424a18f1
BLAKE2b-256 94808c80ecced68c1a516a65b024ca0565c093ea74b004d3e7c8791d3e3ac71d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlr8-0.1.9-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.7

File hashes

Hashes for xlr8-0.1.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f6cc2dc350371f9230af148ca201729380214b3782526fad5a2a50fbfd73f0a6
MD5 81cf537fa95dccc7cdbdb4bf3e7394a6
BLAKE2b-256 8bd136cabb9e474dffe93cd05d15714b668aa0d00cdc1f38b711d4a1670e2b81

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c33ba69ff84e9f3f93791c59105976922397a60f915c8a39bb787d765a893e04
MD5 573635caed1cceabc306d3c81d3236ef
BLAKE2b-256 fa4995fc414cc9356786d39952000e3211c3447c9201bd0dbe04f5427642f0e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 59a6ee08751820030ad1a6f9af3d5490f15bf6792546fa31699dd858fad916e1
MD5 33ff8a017c8f197d552a99f177cdf77d
BLAKE2b-256 ab83a924b135df004b078f267649c476fcf1a15703cba86a2109a9435147602b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c66f27d58f1ce5f6ee493ac07c2a1b52e0b3576f0fbc5b6baf8bd59c75f03dc0
MD5 6276bb1b723f41d4810f60e6f18779ec
BLAKE2b-256 318e3022e17a9df085f41abc1a91066a58d0889b01d02910c2e53f0922726538

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.9-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ddece693c625620b90d72e142b64c0c26ad63dab989fdc4fce6f55644f2832ec
MD5 90f87a91bcf3dd754e94a5fec5a53d22
BLAKE2b-256 d5582d97e9f154e58f31c016592d97669877863985137d379e797d529e294ae1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlr8-0.1.9-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.7

File hashes

Hashes for xlr8-0.1.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ab95d3c6e3f26c3033ead7df6e149cad8f535a6406b54b4b0410c7c822ca9657
MD5 ec455f9e2b3ec38d5407fd1d2b846d6c
BLAKE2b-256 7b158a8dadc8fd01ffc43f165057be173d1644611cfc5cd56b6fb95bd7cfec41

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 59d0b3f501ec7b29bc74c912f1ab155fbb8b3be85d1fc3bdfe1a71e2a4f5fcc0
MD5 b44c7abe41f982652f6630c053b5fd2b
BLAKE2b-256 363dd1883bad555587e0de29b58329cb4c3a390edae9ab7afd1dc2afcb6edfd2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 357bb122e3e0011ee9d1835cfbb2f56b281e90e040b1a7b7b4b51ffc6d8208e5
MD5 307581845bbce809de2895f4652aecb7
BLAKE2b-256 099cd75d5c444432c1da1d9a1ce1b4257879a0d0c27207a0b2cff5c58c19619a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 575e49f7ea0d8f606acfe63367a6553047a73997d5766e8101966f4dd0921c3b
MD5 0a8ed311697058fb15bcb2b737e15750
BLAKE2b-256 6d7a9cc39ad12e165e36960822268617d10345a5bb1b58662236d3be50c942d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.9-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e3f0a6afcb15a6d93c090a438b2736cf10063d08f8054ddddd356e8d2b73ba6e
MD5 3ebbc9358e8664fb584b670e58aa6ff9
BLAKE2b-256 8662875d66d0f1bd801aa0876a51dc97347e8bea8333622ca432994a91ee5a4d

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