In this tutorial we will show you how to improve the performance of the Supabase Connector for the React Native To-Do List demo app.
The demos in the powersync-js monorepo provide a minimal working example that illustrate the use of PowerSync with different frameworks. The demos are therefore not necessarily optimized for performance and can therefore be improved.
This tutorial demonstrates how to improve the Supabase Connector’s performance by implementing two batching strategies that reduce the number of database operations.
The two batching strategies that will be implemented are:
Sequential Merge Strategy
Overview:
PUT
and DELETE
operations for the same tableShoutout to @christoffer_configura for the original implementation of this optimization.
Pre-sorted Batch Strategy
Overview:
putOps
: For PUT
operations, organized by table namedeleteOps
: For DELETE
operations, organized by table namepatchOps
: For PATCH
operations (partial updates)Operation grouping strategy
Batching methodology
MERGE_BATCH_LIMIT
Handling of CRUD operations (PUT, PATCH, DELETE) to sync local changes to Supabase
Transaction management with getNextCrudTransaction()
Implement similar error handling for fatal and retryable errors
Complete the transaction after successful processing
Operation grouping strategy
Batching methodology
You need more granular control over batch sizes
You want more detailed operation logging
You need to handle mixed operation types more efficiently
Best for: Mixed operation types
Optimizes for: Memory efficiency
Trade-off: Potentially more network requests
You have a large number of similar operations.
You want to minimize the number of network requests.
Best for: Large volumes of similar operations
Optimizes for: Minimal network requests
Trade-off: Higher memory usage
In this tutorial we will show you how to improve the performance of the Supabase Connector for the React Native To-Do List demo app.
The demos in the powersync-js monorepo provide a minimal working example that illustrate the use of PowerSync with different frameworks. The demos are therefore not necessarily optimized for performance and can therefore be improved.
This tutorial demonstrates how to improve the Supabase Connector’s performance by implementing two batching strategies that reduce the number of database operations.
The two batching strategies that will be implemented are:
Sequential Merge Strategy
Overview:
PUT
and DELETE
operations for the same tableShoutout to @christoffer_configura for the original implementation of this optimization.
Pre-sorted Batch Strategy
Overview:
putOps
: For PUT
operations, organized by table namedeleteOps
: For DELETE
operations, organized by table namepatchOps
: For PATCH
operations (partial updates)Operation grouping strategy
Batching methodology
MERGE_BATCH_LIMIT
Handling of CRUD operations (PUT, PATCH, DELETE) to sync local changes to Supabase
Transaction management with getNextCrudTransaction()
Implement similar error handling for fatal and retryable errors
Complete the transaction after successful processing
Operation grouping strategy
Batching methodology
You need more granular control over batch sizes
You want more detailed operation logging
You need to handle mixed operation types more efficiently
Best for: Mixed operation types
Optimizes for: Memory efficiency
Trade-off: Potentially more network requests
You have a large number of similar operations.
You want to minimize the number of network requests.
Best for: Large volumes of similar operations
Optimizes for: Minimal network requests
Trade-off: Higher memory usage