Merge slows down when the table grows with liquid clustering enabled.

filipniziol
Esteemed Contributor

Hi Everyone,

I have a source table and target table and MERGE statement that is inserting/updating records every couple of minutes.

The clustering keys are set up to match the 2 merge join columns.

I noticed that with time the processing time increases, which means with bigger target dataset it is harder and harder to find the matching records.

I would hope that liquid clustering works as indexing, so it would be always fast to find the matching records, no matter the size of target dataset.


How to solve this problem?


I am thinking about:
1. Get rid of updates, make silver table append only and use state table to keep the "current" records. Merge source with "current" records and then append records to silver.

2. Create another column "Is current". Add it to liquid clustering. With every processing, add is current to join condition. Then update "Is current" to false for all the records, that do not belong to current update.

Any thoughts?