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. > Optimizing Storage Using TiDB Placement Rules

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.

Abishek S September 10, 2026

Subscribe for email updates

Summarize with AI: ChatGPT Google AI Perplexity Claude Grok

In today's data trend, there is an exponential increase in the amount of data being stored and processed. As datasets grow larger, balancing cost factors with usability and performance becomes a significant challenge. 

 

Organizations today are not only focused on storing immense volumes of data but also seek solutions that optimize data accessibility and performance.

 

TiDB's placement rules address this challenge by enabling the strategic allocation of data, optimizing both performance and resource utilization, and managing costs effectively. By intelligently distributing data, TiDB optimizes performance and resource utilization, effectively managing costs while ensuring data remains readily available when needed. 

 

Placement Rules in TiDB

 

TiDB allow you to control the placement of data within a TiKV cluster through SQL statements. This feature lets you organize data at the cluster, database, table, or partition level assigning it to specific regions, data centers, racks, or hosts as needed.

 

Use Cases : 

  • Distribute data across multiple data centers to enhance high availability strategies.
  • Combine databases from various applications while physically isolating user data, meeting specific isolation needs within a single instance.
  • Boost the number of replicas for critical data to ensure higher application availability and data reliability.

 

Example:

 

For one of our clients, a finance company handling a high volume of invoices, managing data efficiently became a challenge due to all the data being stored in a single table. To address this, we proposed partitioning the table by date ranges and implementing TiDB placement rules to optimize storage and performance.

 

By partitioning the table, we were able to store the most recent data on hot storage for fast access and move older data to cold storage, reducing costs. TiDB placement rules allowed us to assign each partition to the appropriate storage tier, ensuring optimal performance and cost efficiency.

 

Here’s how we achieved the placement policies:

 

Steps to apply Placement policies

 

Create placement labels in the TiKV nodes.  Two nodes are performance, and one is a high-performance node.

 

  • Low-performance nodes for rarely used data, which is cold data.
  • High-performance node for the live data.

 

Checking the placement labels:

 

mysql> SHOW PLACEMENT LABELS;
+-------------+-----------------+
| Key         | Values          |
+-------------+-----------------+
| performance | ["high", "low"] |
| zone        | ["z1", "z2"]    |
+-------------+-----------------+
2 rows in set (0.01 sec)

 

Creating Placement policies:

 

High performance node

 

mysql> CREATE PLACEMENT POLICY hot CONSTRAINTS="[+performance=high]";
Query OK, 0 rows affected (0.97 sec)

 

Low performance node

 

mysql> CREATE PLACEMENT POLICY cold CONSTRAINTS="[+performance=low]";
Query OK, 0 rows affected (1.02 sec)

 

Checking the TiKV nodes:

 

mysql> SELECT store_id, address, label FROM information_schema.tikv_store_status ;
+----------+------------------+---------------------------------------------------------------------------+
| store_id | address          | label                                                                     |
+----------+------------------+---------------------------------------------------------------------------+
|        1 | 172.17.0.5:20160 | [{"key": "performance", "value": "low"}, {"key": "zone", "value": "z1"}]  |
|        2 | 172.17.0.7:20160 | [{"key": "performance", "value": "high"}, {"key": "zone", "value": "z2"}] |
|        5 | 172.17.0.6:20160 | [{"key": "performance", "value": "low"}, {"key": "zone", "value": "z1"}]  |
+----------+------------------+---------------------------------------------------------------------------+
3 rows in set (0.01 sec)

 

Create or Alter the table with partitions:

 

CREATE TABLE invoice (
   invoice_id INT AUTO_INCREMENT,
   amount DECIMAL(10, 2),
   invoice_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
   customer_id INT,
   PRIMARY KEY (invoice_id, invoice_date) 
)
PARTITION BY RANGE (UNIX_TIMESTAMP(invoice_date)) (
   PARTITION p01 VALUES LESS THAN (UNIX_TIMESTAMP('2024-01-01 00:00:00')) PLACEMENT POLICY=cold,
   PARTITION p02 VALUES LESS THAN (UNIX_TIMESTAMP('2024-06-01 00:00:00')) PLACEMENT POLICY=cold,
   PARTITION p03 VALUES LESS THAN (UNIX_TIMESTAMP('2024-11-01 00:00:00')) PLACEMENT POLICY=cold,
   PARTITION p04 VALUES LESS THAN (UNIX_TIMESTAMP('2024-12-01 00:00:00')) PLACEMENT POLICY=hot,
   PARTITION p05 VALUES LESS THAN (MAXVALUE) PLACEMENT POLICY=hot
);

 

P01: Invoices before Jan 01, 2024 (cold storage).

 

P02: Invoices before Jun 01, 2024 (cold storage).

 

P03: Invoices before Nov 01, 2024 (cold storage).

 

P04: Invoices before Dec 01, 2024 (hot storage).

 

P05: Invoices after Dec 01, 2024 (hot storage).

 

Verify the region and partition mapping:

mysql> SELECT trs.partition_name,trp.region_id, trp.store_id FROM information_schema.tikv_region_status trs JOIN information_schema.tikv_region_peers trp ON trp.region_id = trs.region_id  where trs.db_name='test' AND trs.table_name='invoice' AND trs.is_index = 0 AND trp.is_leader = 1 order by region_id;
+----------------+-----------+----------+
| PARTITION_NAME | region_id | store_id |
+----------------+-----------+----------+
| p01            |     25005 |        5 |
| p02            |     25009 |        5 |
| p03            |     25013 |        1 |
| p04            |     25017 |        2 |
| p05            |     25021 |        2 |
+----------------+-----------+----------+
5 rows in set (0.02 sec)

 

When we query the current data, the high-performance node can be used. And for the old data, low-performance nodes can be used. This can be achieved by using the regions that are mapped below.

 

TiDB Partition

 

Checking the region usage on queries

 

Use the trace command to check the partition pruning and the region usage for the data.

 

Query check 1

 

Checking the region request for the recent data (invoice_date >= '2024-11-01 00:00:00' AND invoice_date < '2024-11-10 00:00:00' ).

 

mysql> Trace SELECT * FROM invoice WHERE invoice_date >= '2024-11-01 00:00:00' AND invoice_date < '2024-11-10 00:00:00';
+------------------------------------------------------------------------+-----------------+------------+
| operation                                                              | startTS         | duration   |
+------------------------------------------------------------------------+-----------------+------------+
| trace                                                                  | 15:44:14.478221 | 7.02749ms  |
|   ├─session.ExecuteStmt                                                | 15:44:14.478231 | 2.597407ms |
|   │ ├─executor.Compile                                                 | 15:44:14.478302 | 954.345µs  |
|   │ └─session.runStmt                                                  | 15:44:14.479297 | 1.486641ms |
|   │   └─TableReaderExecutor.Open                                       | 15:44:14.480585 | 175.913µs  |
|   │     └─distsql.Select                                               | 15:44:14.480664 | 64.599µs   |
|   │       └─regionRequest.SendReqCtx                                   | 15:44:14.480966 | 3.088868ms |
|   │         └─rpcClient.SendRequest, region ID: 25017, type: Cop       | 15:44:14.481033 | 2.946535ms |
|   │           └─tikv.RPC                                               | 15:44:14.481037 | 1.024465ms |
|   │             ├─tikv.Wait                                            | 15:44:14.481037 | 170.095µs  |
|   │             │ └─tikv.GetSnapshot                                   | 15:44:14.481037 | 95.042µs   |
|   │             └─tikv.Process                                         | 15:44:14.481207 | 4.12µs     |
|   └─*executor.TableReaderExecutor.Next                                 | 15:44:14.480859 | 3.428497ms |
+------------------------------------------------------------------------+-----------------+------------+
13 rows in set (0.01 sec)

From the output we can see the query requesting the region 25017 (Hot data) which is in partition P04, high performance node.

 

Query check 2

 

Checking the region request for the old data (invoice_date >= '2024-01-01 00:00:00' AND invoice_date < '2024-02-01 00:00:00').

 

mysql> Trace SELECT * FROM invoice WHERE invoice_date >= '2024-01-01 00:00:00' AND invoice_date < '2024-02-01 00:00:00';
+------------------------------------------------------------------------+-----------------+-------------+
| operation                                                              | startTS         | duration    |
+------------------------------------------------------------------------+-----------------+-------------+
| trace                                                                  | 15:46:05.285536 | 23.206115ms |
|   ├─session.ExecuteStmt                                                | 15:46:05.285545 | 2.119478ms  |
|   │ ├─executor.Compile                                                 | 15:46:05.285585 | 865.709µs   |
|   │ └─session.runStmt                                                  | 15:46:05.286495 | 1.119266ms  |
|   │   └─TableReaderExecutor.Open                                       | 15:46:05.287456 | 134.934µs   |
|   │     └─distsql.Select                                               | 15:46:05.287510 | 55.647µs    |
|   │       └─regionRequest.SendReqCtx                                   | 15:46:05.287774 | 20.168645ms |
|   │         └─rpcClient.SendRequest, region ID: 25009, type: Cop       | 15:46:05.287841 | 20.052818ms |
|   │           └─tikv.RPC                                               | 15:46:05.287845 | 19.036333ms |
|   │             ├─tikv.Wait                                            | 15:46:05.287845 | 119.631µs   |
|   │             │ └─tikv.GetSnapshot                                   | 15:46:05.287845 | 37.721µs    |
|   │             └─tikv.Process                                         | 15:46:05.287965 | 150.857µs   |
|   └─*executor.TableReaderExecutor.Next                                 | 15:46:05.287695 | 20.355452ms |
+------------------------------------------------------------------------+-----------------+-------------+
13 rows in set (0.03 sec)

Here the query requesting the region 25009 (Cold data) which is in partition P01, low performance node.

 

Limitations

 

  • It is advised to keep the number of placement policies within a cluster at 10 or fewer.
  • Limit the total number of tables and partitions associated with placement policies to 10,000 or fewer.
  • Applying placement policies to a large number of tables and partitions can increase the computational load on PD, potentially impacting service performance. 
  • It is best to use the Placement Rules in SQL feature as demonstrated in the PingCAP TiDB documentation, rather than implementing more complex placement policies.

Conclusion

TiDB Placement Rules provide flexible control over data placement, making it possible to keep frequently accessed data on high-performance storage while moving older data to lower-cost storage. This approach helps organizations balance performance, availability, and infrastructure costs.

 

At Mafiree, we help businesses design and optimize TiDB environments based on their workload, performance, and scalability requirements.

FAQ

TiDB Placement Rules allow you to control where data is stored within a TiKV cluster by assigning data to specific regions, data centers, racks, or hosts.
TiDB Placement Rules can place frequently accessed data on high-performance nodes, helping improve access performance for hot data.
By placing older or less frequently accessed data on lower-performance storage while keeping active data on high-performance storage, TiDB Placement Rules can help optimize storage costs.
Yes. Placement policies can be assigned to individual table partitions, allowing different partitions to use different storage tiers based on data requirements.
It is recommended to keep the number of placement policies to 10 or fewer and the total number of tables and partitions associated with placement policies to 10,000 or fewer.

Author Bio

Abishek S

Abishek S is a MongoDB and TiDB Certified DBA at Mafiree with strong expertise in distributed databases, TiDB architecture, and cross-database consistency tools. He writes technical content focused on practical database solutions, data consistency verification, replication strategies, and performance optimization for modern data platforms. His work helps engineers and DBAs improve reliability and efficiency in real-world database operations.

Leave a Comment

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.

  330 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.

  1391 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.

  13182 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.

  2922 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.

  2760 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.

  574 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.

  3234 views
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

  530 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.

  1715 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

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

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

  3041 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