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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

File metadata

  • Download URL: xlr8-0.1.7b3.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.7b3.tar.gz
Algorithm Hash digest
SHA256 6bc7a30ab607854d30f151c6532706668f7a8112bf03e9d61780cdecff59c670
MD5 58cd3b304bd5569baff34d33e572f0b9
BLAKE2b-256 ebec008134a121703b711fbf80ffed67afae6cd6c7bffaf6f26ff22423b05620

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlr8-0.1.7b3-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.7b3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f5091cc94f9a2b8e179cc31f8153aab20d6b69b3d231a8b6b08e5f99df3387e8
MD5 261c7f4a518ddcc5ed808361aed3051e
BLAKE2b-256 12517fb89bcafae07cc550b70b11188a49b649ef7a2bd532d6121b85fe0970d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b0ede1cbccc9464e50ad027b886c9fd3f7481a374f30865e98b8953b8e6dfb9a
MD5 fb16b0c7aed10fbf8b26092098ba5fdd
BLAKE2b-256 15e8467819098a9fb958bfc157e078e499e252c6dd65ab43d3b33bb45620867e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d4414a1ebf7ab6ecd7689b01e57a765883c63955269a7d6977b25dec0a921168
MD5 db5b4852355a375e07a34197e5c50678
BLAKE2b-256 95a02f25f912451edf27a2962f7b42e9a456ca9fa48ddd0e0d011e3509f9c3a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f32a27a763358d65af080f7beec446f91ad49aaebe70433c7799079d316b7ec2
MD5 778898a54c8204a9d025574d53bb3425
BLAKE2b-256 1e00801685eb7bfbeec2a306cfb10129110d7aafaa55cfb45f0360e284017169

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b3-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f60183bb590b0eb6d75302cf0448f3bafebb86ad9ff5a773110582eba2a7ce85
MD5 f7860f9a70652e29d8893d6e27ac1691
BLAKE2b-256 acb590a3d4cb731a0109ddedfb44c5c3bb219e27f1a4f8501c2289b70bd5c47e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlr8-0.1.7b3-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.7b3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b3a6804ed389f72821ce119db679a0c4ac2b5c4ec5e94659ae4a6770f0928d9a
MD5 efd1e56e0eddb3a57c73a291466cc69d
BLAKE2b-256 fb1ff4e37c7b9a1c2e7cf8fe79b6cd47ea230bc2c9c9107637b32a23db7c0311

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9df711cb6dc5b23c686b698612283c9c0b148cac3e7e9798022e1a55f7f8e1eb
MD5 1072b25c7434f96c2536e7b936c3aaf1
BLAKE2b-256 c8329414432281c38b61f878ea6d950c3264ecbfc68e375dc31898cb53bcdccf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 39dd15a195b1152b4619104a496b50dfbafda4730e9e97b11757aadd76964f69
MD5 306e7f69ca836938eb8c2f3e31a290ef
BLAKE2b-256 f465fbcaca51d253607eaf66896774b0109f240d6fac19e9c078f1e849435462

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8eeef96f9afa25a296e8fba97e54103cda4c82d44eef7f1365a2a5cc525312bf
MD5 39ff2e7483d6324bcf8f709416645493
BLAKE2b-256 79f9af28ad8ec736187950283293e8601ba137a0ce5da028e170adcfc6181498

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b3-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 55de63c658845c37dd668a6d6cbc4ebc3738cb296329c460a4eb0662c1a51481
MD5 c41c19a1d7313bd0a53665bf75b0e7e5
BLAKE2b-256 f36564ab2496daf8d9f7c5d11c8c5b06429fe98d294debcb29cba0ff79b48a01

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlr8-0.1.7b3-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.7b3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a763dfa4660eb1347c600f9fcae2e4a5593dac2cf4bfe0e18b330dc1cb27493e
MD5 42fd45e4c67847291f589a7b4378db10
BLAKE2b-256 2accfe4eb34b925de0029983b2a81cf7879846c9ea9dd57aac97d436c5869acc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 14fffefc9bdb43e0e2e22891528e7a11ef17d0a0ba8d1f0a371192de848e6005
MD5 abbcbdd36393310200ea6f4ebd16ba40
BLAKE2b-256 8c8e4bbb6841f445b8797273cd3f619c8684811520f995e112be9b0f9e8f788a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a6e9327f34125d459025b215cb12c82e826085326d4d31401b7c83571f1ce67f
MD5 7ecfc510ced6ddbf1fd6a2c78e807629
BLAKE2b-256 7e46b505f925e5588449f74a7794fbcebea3c0ff4205c802fdecc29bfcd2136e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a2441409e2a7ae2c0bd3ca1dab2971d6ed07c70db7cf2501dc0bc1c79f6bc18
MD5 38c836f0c470ce43f945c54c5e9697f2
BLAKE2b-256 1b55d929992fb46b2c7fd9532303e1bc0a20ff44f670f27e07313a43a4287c63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlr8-0.1.7b3-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 cd6919ec8f920646ef58b9346026a94aa14bfc497b4eb762debef7697daea3b7
MD5 f7d6ca9ebc5ea0b57fb6ea4b887a5508
BLAKE2b-256 88055b1b3c8961c6c6fa67b3ab7510841802b71feb50812eca0150a7983c14aa

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