Skip to main content

MariaDB Binlog Indexer for Faster Querying

Project description

MariaDB Binlog Indexer

This tool helps to index mariadb binlogs and store them in compact format to query faster.

File Format

  • DuckDB - Store all the metadata of binlogs.
  • Parquet - Store the actual queries.

DB Schema

┌─────────────┬─────────────┬─────────┬─────────┬─────────┬─────────┐
│ column_name │ column_type │  null   │   key   │ default │  extra  │
│   varchar   │   varchar   │ varchar │ varchar │ varchar │ varchar │
├─────────────┼─────────────┼─────────┼─────────┼─────────┼─────────┤
│ binlog      │ VARCHAR     │ YES     │ NULL    │ NULL    │ NULL    │
│ db_name     │ VARCHAR     │ YES     │ NULL    │ NULL    │ NULL    │
│ table_name  │ VARCHAR     │ YES     │ NULL    │ NULL    │ NULL    │
│ timestamp   │ INTEGER     │ YES     │ NULL    │ NULL    │ NULL    │
│ type        │ VARCHAR     │ YES     │ NULL    │ NULL    │ NULL    │
│ row_id      │ INTEGER     │ YES     │ NULL    │ NULL    │ NULL    │
│ event_size  │ INTEGER     │ YES     │ NULL    │ NULL    │ NULL    │
└─────────────┴─────────────┴─────────┴─────────┴─────────┴─────────┘

Usage

Before starting up please note down,

  • All the timestamps are in seconds UTC
  • Available query types are SELECT, INSERT, UPDATE, DELETE, OTHER

Also, check the python docstrings for more details.

Initialize Indexer

from mariadb_binlog_indexer import Indexer

indexer = Indexer(
    base_path="<path to store indexer related files>",
    db_name="metadata.db", # The name of the database to store metadata
)

Index New Binlog

indexer.add(
    binlog_path="<path to binlog>",
    batch_size=10000, # The batch size to insert binlog in duckdb
)

Remove Indexes of Binlog

indexer.remove(
    binlog_path="<path to binlog>",
)

Generate Timeline

This function will provide a summary of binlog event in a given time range. It will split the time range into 30 parts and provide event related information for each part.

indexer.get_timeline(
    start_timestamp=1746534427, # The start timestamp in seconds UTC
    end_timestamp=1756534427, # The end timestamp in seconds UTC,
    type="INSERT", # Optional
    database="test_db", # Optional
)

Get Row Ids

This function will help to get the row ids of each binlog based on our request. The purpose of this function is to help finding required row ids beforehand to implement pagination on the other end.

Only reason of doing this is to reduce the search in the parquet files.

indexer.get_row_ids(
    start_timestamp=1746534427, # The start timestamp in seconds UTC
    end_timestamp=1756534427, # The end timestamp in seconds UTC,
    type="INSERT", # Optional
    database="test_db", # Optional
    table="test_table", # Optional
    search_str="test", # Optional
)

Get Queries from Parquet Files

This function will help to get the queries from parquet files.

indexer.get_queries(
    row_ids={
        "binlog_1": [101, 102, 103],
        "binlog_2": [104, 105, 106],
    },
    database="test_db", # Optional
)

You need to provide database name as filtering purpose only.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file mariadb_binlog_indexer-0.0.5-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mariadb_binlog_indexer-0.0.5-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b314368ad81789d3600fc2ea9ea19ff6567ee7120085d50333bb8752b0c48368
MD5 a18a23f78c7aa1e50144c167a7e4c939
BLAKE2b-256 12203c62e6eacbcc0c97ddb38e751a8849a186c20c404afc3fbef4dc8c366b31

See more details on using hashes here.

File details

Details for the file mariadb_binlog_indexer-0.0.5-py3-none-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mariadb_binlog_indexer-0.0.5-py3-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6fbfe666660a7fa77a84cbf9c2c519abb503a797c09f7822235c9d85a0a59206
MD5 f09cb8d54b214b269b4e34a9182db555
BLAKE2b-256 2350e8d2fe07f1e00f92365e7b3f244a1b1df735ef33418d7017476142cf844a

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