Incremental processing using a timestamp
You can process records incrementally by filtering on a timestamp “last update”. By storing the highest timestamp that was already processed in the state, you implement a stateful script that will only process new and updated records on each run. Here is an example script using a timestamp stored in the state of the script:Incremental processing by comparing source and destination
This pattern is more advanced than the pattern using a timestamp because when using a timestamp a record will only be processed once and if writeback fails for that specific record, it will not be picked up again in the future. An alternative pattern is to compare the data from source and destination using a JOIN query in Peliqan first, and using the result of that JOIN query as input for the sync script to process records. Example JOIN query to compare data from a source and a destination:Getting and setting state in a script
A script is stateful when it keeps track of its state across runs.- String: e.g. store the guid of the last processed record (assuming records are sorted) or store the highest timestamp processed
- Number: e.g. store the id of the last processed record (assuming records are sorted)
- Dict: store multiple states, e.g. one for each table
