We have a client case where a huge table - that needs to be loaded incrementally- does not have any changed field. Because of legacy issues, it’s not possible to d introduce a rowversion or Change tracking on SQL Server. The ODX is on a datalake, while the MDW on Azure SQL Server.
The proposed solution tries to identify which rows have been updated in the table, here's a streamlined approach:
- Calculate Total Rows: First, get the total number of rows in the table
- Initial Range: Start with the full range of IDs, from the minimum to the maximum ID in the target table.
- Recursive Division: Divide the range into two halves and calculate a checksum for each half: checksum_agg(checksum(ID * EntryType)). The checksum combines IDs and EntryType values to create a unique fingerprint for that segment.
- Compare Checksums:
- If the checksums match, no updates in that segment.
- If they differ, further divide the segment with the differing checksum into smaller halves and repeat the process.
- Threshold for Division: Continue dividing until the segment size is smaller than the square root of the total row count. This helps us quickly narrow down potential updates.
- Identify Updates: For small segments (below the threshold), directly compare the rows in the source and target tables to find where row has changed.
We can efficiently find updates without having to compare every single row, by focusing only on segments where changes are likely.
It would be great if such functionality can be implemented in TimeXtender :-)