The batch on delete statement generates uneven job batch size.
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Enhancement
We use 'date_sub(subdate(curdate(), interval 7 days), interval 1 second)' to create the selection range for calculating the job's deletion range. However, the job's runtime may exceed one day. As a result, on the following day, when new jobs use this condition to delete data, they will delete more data than anticipated due to the change in the time range. This could lead to some jobs being terminated due to memory-quota-limit. Therefore, I believe we need additional features to address this scenario.
User command:
```
batch on _tidb_rowid limit 20000 delete from test where bat_time <= subdate ( curdate (), 7) - interval 1 second;
```
SQL generated by TiDB:
```
delete from test where _tidb_rowid between xxxx and xxxx and bat_time <= subdate ( curdate (), 7) - interval 1 second
```
Contributor guide
Assessment
This issue has not been assessed yet.