Will a large number of empty-region-count cause slow response, and how to reduce empty-region-count

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 大量的empty-region-count会不会导致 响应变慢,如何降低empty-region-count

| username: fly4310862

[TiDB Usage Environment] Production Environment / Testing / Poc
[TiDB Version] 4.0.8
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Problem Phenomenon and Impact]

Currently, the business feedback indicates that TiDB is gradually slowing down. Is it related to the large number of empty-region-count? How to reduce empty-region-count?

[Resource Configuration]
[Attachments: Screenshots/Logs/Monitoring]
–1. PD parameter configuration:
» config show
{
“replication”: {
“enable-placement-rules”: “false”,
“location-labels”: “”,
“max-replicas”: 3,
“strictly-match-label”: “false”
},
“schedule”: {
“enable-cross-table-merge”: “false”,
“enable-debug-metrics”: “false”,
“enable-location-replacement”: “true”,
“enable-make-up-replica”: “true”,
“enable-one-way-merge”: “false”,
“enable-remove-down-replica”: “true”,
“enable-remove-extra-replica”: “true”,
“enable-replace-offline-replica”: “true”,
“high-space-ratio”: 0.6,
“hot-region-cache-hits-threshold”: 3,
“hot-region-schedule-limit”: 4,
“leader-schedule-limit”: 4,
“leader-schedule-policy”: “count”,
“low-space-ratio”: 0.8,
“max-merge-region-keys”: 200000,
“max-merge-region-size”: 0,
“max-pending-peer-count”: 8,
“max-snapshot-count”: 3,
“max-store-down-time”: “30m0s”,
“merge-schedule-limit”: 8,
“patrol-region-interval”: “100ms”,
“region-schedule-limit”: 4,
“replica-schedule-limit”: 4,
“scheduler-max-waiting-operator”: 5,
“split-merge-interval”: “1h0m0s”,
“store-limit-mode”: “manual”,
“tolerant-size-ratio”: 5
}
}

–2. Monitoring of empty-region-count


| username: weixiaobing | Original post link

The max-merge-region-size controls the upper limit of the Region Merge size (in MiB). When the Region Size exceeds the specified value, PD will not merge it with adjacent Regions. Setting it to 0 means the Region Merge feature is disabled.

| username: fly4310862 | Original post link

I see, thank you~~

| username: xfworld | Original post link

Regions require resources for heartbeat processing, which consumes CPU, memory, and network resources. Typically, after a large number of delete operations, empty regions are generated and need to be merged quickly to reduce resource consumption.

| username: 裤衩儿飞上天 | Original post link

  1. A large number of empty regions will definitely consume resources.
  2. Are there any truncate table operations or delete operations in the business?
  3. You can enable enable-cross-table-merge, which is disabled by default in version 4.0.8.