Manually deleting data causes TiCDC delay issues. I still don't quite understand the specific logic behind this. Can someone explain it to me?

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

Original topic: 手动delete数据,会导致ticdc delay问题,这个具体是什么逻辑我还是没太明白,哪个老师帮我解释一下呀

| username: jaybing926

As mentioned, my foundation is too weak and I don’t have time to thoroughly read the documentation. I’m asking for a teacher to explain it, thank you~

I want to understand the principles.

| username: xfworld | Original post link

It’s quite simple. The delete SQL will affect TiKV, and TiCDC will capture the data change events in TiKV.

If there are a lot of rows being deleted, for example, 500,000 rows, which is quite common,
then TiCDC will also replay 500,000 row events to the downstream. At this point, two issues may arise:

  1. Whether the resources allocated for the TiCDC changefeed are sufficient to handle this scale.
  2. Whether the downstream service connected to TiCDC has enough resources to handle this scale.

If not, TiCDC will experience delays…

| username: jaybing926 | Original post link

Is it just because the processing capacity of the TiCDC node is insufficient?
Does it have anything to do with GC compact?

| username: Hacker007 | Original post link

If a single transaction processes a large amount of data, won’t other transactions have to wait? If the upstream has this operation, it will also cause DM synchronization delays or synchronization anomalies.

| username: xfworld | Original post link

The operations of GC or compact are targeted at TiKV…

Both GC and compact will occupy TiKV’s resources.

As for the issue of large transactions, it should also be taken into account… This thing will consume a lot of memory… :see_no_evil:

It seems that the new version has some optimizations for large transactions, allowing them to be executed in batches. I forgot which version it was.

| username: jaybing926 | Original post link

Okay, thank you.

| username: yytest | Original post link

DELETE is a DML command. If you want to delete the entire table, using the DROP DDL command is faster.

| username: 小于同学 | Original post link

Same question.

| username: xfworld | Original post link

“Truncate table will be faster. Drop deletes the entire table, which is different…”

| username: TiDBer_H5NdJb5Q | Original post link

If truncate is used, does CDC only have one truncate command without other data being sent?

| username: ZZH-QK | Original post link

Batch deletion of historical data is indeed a big headache. If partitioned tables are used, there will be the headache of extremely long ANALYZE times:

| username: zhanggame1 | Original post link

Deleting a little bit each day is the most reasonable approach.

| username: Jack-li | Original post link

Well explained!

| username: yytest | Original post link

Indeed, DDL is faster than DML when it comes to deleting data.

| username: FutureDB | Original post link

This is indeed quite troublesome. Partition tables can solve the problem of deleting large amounts of historical data, but partition tables themselves have some issues, making it difficult to balance.

| username: 友利奈绪 | Original post link

Does this mean that after importing incremental data every day, a portion of it is batch deleted?

| username: zhanggame1 | Original post link

Yes, taking it slowly has a smaller impact on cluster stability.