Mafiree logo
  • About
  • Services
  • Blogs
  • Careers
  • Products
    • orbit logo Orbit
    • streamer logo Xstreami
  • Contact
Schedule a Call
Menu
  • About
  • Services
  • Blogs
  • Careers
  • Products
    • orbit logo Orbit
    • streamer logo Xstreami
  • Contact
  • Schedule a Call
Database
Database Managed Database Services
MySQL MySQL
MySQL Consulting
MySQL Migration Services
MySQL Optimization & Query Tuning
MySQL Database Administration
MySQL Backup & Recovery
MySQL Security & Maintenance
MySQL Cloud Services (AWS RDS, Aurora, Google Cloud SQL, Azure)
MySQL for Ecommerce
MySQL High Availability & Replication
MongoDB MongoDB
MongoDB Consulting
MongoDB Migration Services
MongoDB Optimization & Query Tuning
MongoDB Database Administration
MongoDB Backup & Recovery
MongoDB Security & Maintenance
MongoDB Cloud (Atlas)
MongoDB Solutions by Industry
MongoDB High Availability & Replication
PostgreSQL PostgreSQL
PostgreSQL Consulting
PostgreSQL Migration & Upgrades
Performance Tuning & Query Optimization
PostgreSQL Administration & Managed Services
High Availability, Clustering & Replication
PostgreSQL Backup, Recovery & Disaster Planning
PostgreSQL Security, Compliance & Auditing
PostgreSQL for Analytics & Data Warehousing
PostgreSQL on Cloud & Containers
PostgreSQL Extensions & Open-Source Integrations
PostgreSQL for Every Industry
SQL Server MSSQL
MSSQL Consulting
MSSQL Migration Services
MSSQL Optimization & Query Tuning Services
MSSQL Database Administration Services
MSSQL Backup & Recovery Services
MSSQL High Availability & Replication Services
MSSQL Security & Compliance Services
MSSQL Performance Monitoring & Health Checks
MSSQL Solutions by Industry
Aerospike Aerospike
Aerospike Consulting
Aerospike Migration Services
Aerospike Performance Optimization & Tuning
Aerospike Backup & Recovery
Aerospike High Availability
Aerospike Cloud & Hybrid Deployments
Aerospike for Real-Time Applications (AdTech, FinTech, Retail, IoT)
Clickhouse Clickhouse
ClickHouse Consulting
ClickHouse Migration Services
ClickHouse Optimization & Query Tuning
ClickHouse Database Administration
ClickHouse Backup & Recovery
ClickHouse Security & Maintenance
ClickHouse Cloud Services (ClickHouse Cloud, AWS, GCP, Azure)
ClickHouse Solutions by Industry
ClickHouse High Availability & Replication
TiDB TiDB
TiDB Consulting
TiDB Administration & Maintenance
TiDB Security and Privacy Maintenance
TiDB Performance & Query Optimization
TiDB Migration Services
TiDB Backup & Disaster Recovery
TiDB High Availability Solutions
TiDB Solutions by Industry
TiDB Cloud Services
ScyllaDB ScyllaDB
ScyllaDB Consulting
ScyllaDB Administration & Maintenance
ScyllaDB Security and Privacy Maintenance
ScyllaDB Performance & Query Optimization
ScyllaDB Migration Services
ScyllaDB Backup & Disaster Recovery
ScyllaDB High Availability Solutions
ScyllaDB Solutions by Industry
ScyllaDB Cloud Services
DevOps
DevOps DevOps Services
Version Control Version Control
Kubernetes Kubernetes
Infrastructure Infrastructure Management
Web Servers Web Servers
Networking
Networking Networking Services
Basic Basic
Advanced Advanced
MySQL MySQL
MongoDB MongoDB
PostgreSQL PostgreSQL
MSSQL MSSQL
Aerospike Aerospike
Clickhouse Clickhouse
TiDB TiDB
ScyllaDB ScyllaDB
Version Control Version Control
Kubernetes Kubernetes
Infrastructure Infrastructure Management
Web Servers Web Servers
Basic Basic
Advanced Advanced
MySQL Consulting
MySQL Migration Services
MySQL Optimization & Query Tuning
MySQL Database Administration
MySQL Backup & Recovery
MySQL Security & Maintenance
MySQL Cloud Services (AWS RDS, Aurora, Google Cloud SQL, Azure)
MySQL for Ecommerce
MySQL High Availability & Replication
MongoDB Consulting
MongoDB Migration Services
MongoDB Optimization & Query Tuning
MongoDB Database Administration
MongoDB Backup & Recovery
MongoDB Security & Maintenance
MongoDB Cloud (Atlas)
MongoDB Solutions by Industry
MongoDB High Availability & Replication
PostgreSQL Consulting
PostgreSQL Migration & Upgrades
Performance Tuning & Query Optimization
PostgreSQL Administration & Managed Services
High Availability, Clustering & Replication
PostgreSQL Backup, Recovery & Disaster Planning
PostgreSQL Security, Compliance & Auditing
PostgreSQL for Analytics & Data Warehousing
PostgreSQL on Cloud & Containers
PostgreSQL Extensions & Open-Source Integrations
PostgreSQL for Every Industry
MSSQL Consulting
MSSQL Migration Services
MSSQL Optimization & Query Tuning Services
MSSQL Database Administration Services
MSSQL Backup & Recovery Services
MSSQL High Availability & Replication Services
MSSQL Security & Compliance Services
MSSQL Performance Monitoring & Health Checks
MSSQL Solutions by Industry
Aerospike Consulting
Aerospike Migration Services
Aerospike Performance Optimization & Tuning
Aerospike Backup & Recovery
Aerospike High Availability
Aerospike Cloud & Hybrid Deployments
Aerospike for Real-Time Applications (AdTech, FinTech, Retail, IoT)
ClickHouse Consulting
ClickHouse Migration Services
ClickHouse Optimization & Query Tuning
ClickHouse Database Administration
ClickHouse Backup & Recovery
ClickHouse Security & Maintenance
ClickHouse Cloud Services (ClickHouse Cloud, AWS, GCP, Azure)
ClickHouse Solutions by Industry
ClickHouse High Availability & Replication
TiDB Consulting
TiDB Administration & Maintenance
TiDB Security and Privacy Maintenance
TiDB Performance & Query Optimization
TiDB Migration Services
TiDB Backup & Disaster Recovery
TiDB High Availability Solutions
TiDB Solutions by Industry
TiDB Cloud Services
ScyllaDB Consulting
ScyllaDB Administration & Maintenance
ScyllaDB Security and Privacy Maintenance
ScyllaDB Performance & Query Optimization
ScyllaDB Migration Services
ScyllaDB Backup & Disaster Recovery
ScyllaDB High Availability Solutions
ScyllaDB Solutions by Industry
ScyllaDB Cloud Services
  1. Home
  2. > Blogs
  3. > TiDB
  4. > How Selective Row Replication Works: MySQL to TiDB

How Selective Row Replication Works: MySQL to TiDB

Analytics with TiDB's Row-Wise Filtering. Discover how our client slashed costs and boosted flexibility with TiDB's granular data management features. Dive into the future of database optimization with Mafiree

sukan September 10, 2026

Subscribe for email updates

Summarize with AI: ChatGPT Google AI Perplexity Claude Grok

One of our esteemed customers, a prominent player in the realm of video streaming services, faced a unique challenge. Tasked with delivering an exclusive feature tailored for Platinum subscription holders, their MySQL database was straining under the weight of resource-intensive aggregate queries.

 

A separate dashboard, log streaming, and other essential features were in demand, making it clear that a more robust solution was needed.

 

We have created a TiDB cluster and configured the TiDB cluster as a replica for MySQL.

 

Detailed architecture can be referred from this post

 

Challenges

 

The adoption of TiDB brought about a significant improvement in query performance, thanks to its columnar facility, TiFlash.

 

However, the sheer volume of data, 5TB, to be replicated across various TiDB nodes for OLAP requests was proving to be a costly affair.

 

We uncovered a key feature in TiDB that proved to be useful, i.e., Row-Wise Filtered Replication

 

In TiDB DM, we have many filtering techniques while replicating the data. When we are replicating data in MySQL, MariaDB, Postgresql,etc we can filter the replication at the Database and Table level only.

 

In TiDB, we can filter the replication data at the row level and also filter the binlog events. So, in this blog, we will see how these filtering methods are possible by using TiDB.

 

The following example shows how this feature works

Replicating MySQL to TiDB
 


In the above diagram, we categorized users based on their usage plan, and when we replicate it from MySQL to TiDB, we only replicate the PREMIUM users.

 

The rows that have the PREMIUM user type replicate to the TiDB. This one done by the filter technique used in the DM task.

 

Samples

 

Inserting the data into the table

 

  1. mysql> insert into details(id,name,age,user_type)values(1,'User1',22,'Premium'),(2,'User2',28,'regular'),(3,'User3',19,'Premium'),(4,'User4',21,'Trial');
  2. Query OK, 4 rows affected (0.19 sec)
  3. Records: 4  Duplicates: 0  Warnings: 0

Viewing the data in MySQL

 

  1. mysql> select * from details order by id;
  2. +----+-------+------+-----------+
  3. | id | name  | age  | user_type |
  4. +----+-------+------+-----------+
  5. |  1 | User1 |   22 | Premium   |
  6. |  2 | User2 |   28 | Regular   |
  7. |  3 | User3 |   19 | Premium   |
  8. |  4 | User4 |   21 | Trial     |
  9. +----+-------+------+-----------+
  10. 4 rows in set (0.01 sec)

This output has 4 rows; now let’s check on the TiDB side

 

  1. MySQL [users]> select * from details;
  2. +----+-------+------+-----------+
  3. | id | name  | age  | user_type |
  4. +----+-------+------+-----------+
  5. |  1 | User1 |   22 | Premium   |
  6. |  3 | User3 |   19 | Premium   |
  7. +----+-------+------+-----------+
  8. 2 rows in set (0.00 sec)

With this replication row filter, TiDB has only rows with user_type is PREMIUM.

 

Another feature of TiDB DM replication is we have filter based on binlog events, events such as deletes, drops can be avovied in replication.

 

The following are examples where we can have multiple filters,

ParameterDescription
schema_patternFilters matching the schema
table_patternFilters matching the table
eventsBinlog events (create,insert, update,delete, etc)
actionDo or ignore

Example of how deletes are not replicated to TiDB,

 

In upstream MySQL we are deleting all record from the table.

 

  1. mysql> delete from details;
  2. Query OK, 12 rows affected (0.09 sec)
  3.  
  4. mysql> select * from details;
  5. Empty set (0.02 sec)

Now there are no records in the table and we are checking the TiDB cluster replica.

 

  1. MySQL [users]> select * from details;
  2. +----+-------+------+-----------+
  3. | id | name  | age  | user_type |
  4. +----+-------+------+-----------+
  5. |  1 | User1 |   22 | Premium   |
  6. |  3 | User3 |   19 | Premium   |
  7. +----+-------+------+-----------+
  8. 2 rows in set (0.00 sec)

There are no records deleted from the TiDB cluster. This one is done by the binlog filter configuration.

 

Conclusion

 

In conclusion, TiDB stands out with its native support for features like row-wise filtering, empowering users to optimize storage and compute costs significantly. By selectively replicating only the necessary rows for analytics, our client experienced tangible savings while ensuring seamless data accessibility.

 

Unlike other databases that often provide only table-level filtration, TiDB offers a superior level of flexibility with its granular row-wise filtering capabilities. This ensures that users have precise control over their data, facilitating more efficient and tailored data management strategies.

 

At Mafiree, we’re committed to providing comprehensive solutions tailored to your specific requirements. Our dedicated team of experts is poised to review your setup and offer customized solution architecture recommendations.

For any inquiries or assistance, please don’t hesitate to contact sales@mafiree.com. Your database challenges are our priority, and we’re here to help you navigate them effectively.

FAQ

Selective row replication replicates only specific rows from a source database to a target database based on defined filtering conditions.
TiDB uses TiDB Data Migration (DM) filtering rules to replicate only the required rows based on conditions such as user type or other column values.
Selective row replication helps reduce the amount of data stored and processed in TiDB, which can lower storage and compute costs for analytical workloads.
Yes. TiDB can filter replication at the row level when replicating data from MySQL, allowing only matching records to be transferred to the TiDB cluster.
Yes. TiDB DM supports binlog event filtering, allowing events such as INSERT, UPDATE, DELETE, and other operations to be included or excluded from replication.

Author Bio

sukan

Sukan is Database Team Lead at Mafiree with over a decade of experience in database systems, architecture, and performance optimization. He specializes in MySQL, MongoDB, TiDB, and ClickHouse, developing architectural improvements that make data platforms faster, more efficient, and cost-effective. Sukan writes about practical database engineering topics, real-world performance tuning, data replication, and high-scale system design, drawing from extensive hands-on experience solving complex technical challenges.

Leave a Comment

Comments

S
Sukan December 09, 2024

Hey @Jayson, Costly means the storage & compute cost.

J
Jayson July 03, 2024

can you define "costly" in this sentence "However, the sheer volume of data, 5TB, to be replicated across various TiDB nodes for OLAP requests was proving to be a costly affair." Is it in terms of performance, latency, or bandwidth?

Related Blogs

TiDB Out of Memory (OOM) Errors: Root Cause Analysis & Memory Tuning Guide

TiDB OOM Errors fall into two types — a full node crash triggered by the OS, or a single query cancelled by TiDB's own memory controls. This guide walks through how to confirm which occurred, identify the SQL patterns most responsible (HashJoin, HashAgg, large transactions, stale statistics), configure the four key memory parameters, enable disk spill as a safety net, and verify production readiness with a structured checklist.

  329 views
Manage Large Data Import in TiDB

Managing large-scale data import in TiDB requires specialized tools and strategies due to its distributed architecture. Unlike traditional databases, TiDB must efficiently distribute data across multiple nodes while maintaining consistency and performance. TiDB Lightning is the primary high-performance tool designed for bulk data ingestion, supporting formats like CSV, Parquet, and Dumpling exports. It offers two import modes: physical mode for maximum speed during initial loads and logical mode for safer imports into active production environments. Additionally, TiDB introduces IMPORT INTO, a SQL-based import method that simplifies data loading for moderate datasets with minimal setup. This guide covers TiDB Lightning architecture, import modes, performance comparisons, complete migration workflows, and best practices to help you efficiently manage large amounts of data, avoid common failures, and choose the right import strategy for your use case.

  1387 views
How to Automate Data Deletion Using TiDB TTL

TiDB TTL (Time-To-Live) automatically removes expired rows based on a defined retention period. It helps manage growing datasets, reduce storage usage, and minimize the need for manual cleanup. This guide covers TTL configuration, scheduled cleanup jobs, conditional expiration, monitoring, and key limitations.

  13179 views
Sync-Diff-Inspector: Your Go-To Tool for Verifying Data Consistency Across TiDB and MySQL

A powerful tool to compare, detect, and fix data inconsistencies across distributed databases—ensure accurate migrations and seamless replication with Sync-Diff-Inspector.

  2918 views
The Feature You’ve Been Looking For – Speed Up Your Queries with TiDB Cached Tables!

Boost database performance with TiDB cached tables—reduce latency and accelerate read-heavy queries.

  2754 views
How TiDB 7.4 Resource Isolation Improves Workloads

TiDB Resource Control helps manage resource usage by assigning limits and priorities to different workloads. It allows high-priority applications to get the resources they need while preventing other workloads from affecting critical operations. This is especially useful when multiple teams or workloads share the same TiDB cluster.

  572 views
Introducing Foreign Keys and more: Exploring New Features in TiDB v8.5.0

Explore the latest features in TiDB v8.5.0, including support for Foreign Keys, improved performance, and enhanced security for modern database management.

  3232 views
Optimizing Storage Using TiDB Placement Rules

TiDB Placement Rules help control where data is stored within a TiKV cluster. By assigning data to specific storage tiers, zones, or hosts, they can improve performance, resource utilization, and cost efficiency.

  13145 views
TiDB Pause Resume DDL: Safely Manage Long-Running Schema Changes in Production

TiDB provides a powerful pause and resume DDL feature that allows database administrators to control long-running schema changes without canceling them. Instead of aborting operations like index creation or column modifications during peak traffic, teams can pause the DDL job and resume it later during low-traffic periods. This guide explains how TiDB pause resume DDL works, when to use pause vs resume vs cancel, and provides step-by-step commands for managing DDL operations safely in production environments.

  1712 views
Why TiDB? - 5 Indicators You've Outgrown MySQL

Dive into our blog post to uncover signs that hint it's time to move on from MySQL and find out how TiDB steps up as the ideal solution

  3697 views
Scaling Databases Horizontally: A Solution for High-Concurrency Systems

Blog post on how TiDB handles the OLAP requests without compromising OLTP

  3036 views

Subscribe for email updates

Get in touch with us

Highlights

More than 6000 Servers Monitored

Happy Clients

Certified DBAs

24 x 7 x 365 Support

PCI

Database Services

MySQL MongoDB PostgreSQL SQL Server Aerospike Clickhouse TiDB ScyllaDB

Quick Links

Careers Blog Contact Privacy Policy Disclaimer Policy

Contacts

Linkedin Mafiree Facebook Mafiree Twitter Mafiree

Nagercoil Office

Miru IT Park, Vallankumaranvillai,

Nagercoil, Tamilnadu - 629 002.

Bangalore Office

Unit 303, Vanguard Rise,

5th Main, Konena Agrahara,

Old Airport Road, Bangalore - 560 017.

Call: +91 6383016411

Email: sales@mafiree.com


Copyright © - All Rights Reserved - Mafiree