Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: Placement Rules In SQL 和 Placement Rules 的区别?

I have the following questions:
-
Is it necessary to have a region label when configuring TiKV for Placement Rules In SQL?
-
In the DR Auto-sync adaptive synchronization mode, can the placement rule configuration file be adjusted to the Placement Rules In SQL method?
-
Can Placement Rules In SQL replace Placement Rules? Using Placement Rules requires configuring a configuration file, while Placement Rules In SQL can be done with just one SQL statement.
For example, to achieve 3 replicas and place all table region leaders of the testdb database on TiKV labeled as bj, you can do it like this: -
CREATE PLACEMENT POLICY test_policy PRIMARY_REGION=“bj” REGIONS=“bj,dl,sz” FOLLOWERS=2;
-
create database testdb placement policy=test_policy;
If using the Placement Rules configuration file method:
{
“group_id”: “pd”,
“group_index”: 0,
“group_override”: false,
“rules”: [
{
“group_id”: “pd”,
“id”: “az-east”,
“start_key”: “”,
“end_key”: “”,
“role”: “voter”,
“count”: 1,
“label_constraints”: [
{
“key”: “region”,
“op”: “in”,
“values”: [
“bj”
]
}
],
“location_labels”: [
“rack”,
“dc”,
“region”
]
},
{
“group_id”: “pd”,
“id”: “az-west”,
“start_key”: “”,
“end_key”: “”,
“role”: “follower”,
“count”: 1,
“label_constraints”: [
{
“key”: “region”,
“op”: “in”,
“values”: [
“dl”
]
}
],
“location_labels”: [
“rack”,
“dc”,
“region”
]
},
{
“group_id”: “pd”,
“id”: “az-west”,
“start_key”: “”,
“end_key”: “”,
“role”: “learner”,
“count”: 1,
“label_constraints”: [
{
“key”: “region”,
“op”: “in”,
“values”: [
“sz”
]
}
],
“location_labels”: [
“dc”,
“rack”,
“region”
]
}