Server data cleanup

PocketSync implements a systematic approach to maintain optimal database performance through periodic cleanup of processed changes while ensuring data integrity and sync reliability.

Change processing strategy

To prevent redundant updates and ensure efficient synchronization, the server processes changes before distributing them to client devices:

Change consolidation

Identifying the most recent change per row
  • If the latest change to a row is a deletion, the row is discarded from the change set
  • Updates to the same row are merged based on timestamps and versions to avoid redundant operations
  • Only the final state of each row is propagated to other devices
Change optimization
  • Intermediate states are eliminated to reduce network traffic
  • Multiple updates to the same field are consolidated
  • Conflicting changes are resolved according to configured strategies

Order management

Ensuring order consistency
  • Changes are grouped from oldest to newest
  • Sequential processing ensures correct application order
  • Dependencies between changes are maintained
Version control
  • Each change set maintains version information
  • Devices can verify the completeness of received changes
  • Missing changes can be requested if gaps are detected

Benefits

  • Reduced network traffic: By eliminating redundant changes
  • Improved sync speed: Through optimized change sets
  • Consistent data state: By maintaining proper operation order
  • Resource efficiency: Through periodic cleanup of processed changes