Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: TiDB如何修改默认的PLACEMENT POLICY?
TiDB Version: 6.1.1
Expectation:
Added three SATA disk TiKV nodes, hoping not to trigger normal table region scheduling, and only place a few historical partitions on them. By default, TiDB writes data as evenly as possible, and new regions will also be written to the newly added SATA disk machines (since they are new nodes, normal rebalance will also be triggered). However, I actually do not want normal data to be written to these machines because the read and write performance of SATA disks is very poor.
Problem:
The current idea is to create two PLACEMENT POLICY
, let the normal tables use the on_ssd
policy, and cold data use the on_sata
policy. The policies are as follows:
CREATE PLACEMENT POLICY on_ssd CONSTRAINTS="[-disk=sata]";
CREATE PLACEMENT POLICY on_sata CONSTRAINTS="[+disk=sata]";
However, according to the official documentation on placement-rules-in-sql, you can only create PLACEMENT POLICY and then set it for specific databases/tables/partitions. There is also a note:
Note that the inheritance between partitions and tables is different from the inheritance here. Changing the placement policy of a table will also apply the new policy to its partitions. However, only when no placement policy is specified during table creation will the table inherit the placement policy from the database, and subsequent changes to the database will not affect the already inherited tables.
This means that I need to manually execute ALTER TABLE t2 PLACEMENT POLICY=on_ssd;
for each existing database and table; if a new database is added later, it also needs to explicitly specify the on_ssd
PLACEMENT POLICY.
Requirement:
Is there any way to modify the default PLACEMENT POLICY (i.e., the policy for tables when no PLACEMENT POLICY is explicitly specified)? Or set TiKV to not participate in normal data write scheduling by default, but allow tables with explicitly specified PLACEMENT POLICY to write data to these nodes?