You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: usage/lifecycle-maintenance/compacting-buckets.mdx
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,7 +82,6 @@ DELETE FROM lists WHERE name = 'b';
82
82
83
83
After compacting, the bucket looks like this:
84
84
85
-
86
85
```bash
87
86
(1, PUT, row_1, <data>)
88
87
(2, MOVE)
@@ -95,7 +94,7 @@ After compacting, the bucket looks like this:
95
94
(100001, REMOVE, row50000)
96
95
```
97
96
98
-
This is inefficient, since we have over 100k operations for downloading a single actual row.
97
+
This is inefficient, since we have over 100k operations for downloading a single row.
99
98
100
99
To handle this case, we "defragment" the bucket by updating existing rows in the source database. In this case, we can run:
101
100
@@ -115,6 +114,10 @@ This creates a new PUT operation at the end of the bucket, which allows the comp
115
114
116
115
The bucket is now back to two operations, allowing new clients to sync efficiently.
117
116
117
+
<Check>
118
+
Note: All rows in the bucket must be updated for this to be effective.
119
+
</Check>
120
+
118
121
### Defragmenting trade-offs
119
122
120
123
Defragmenting + compacting as described above can significantly reduce the number of operations in a bucket, at the cost of existing clients needing to re-sync that data. When and how to do this depends on the specific use-case and data update patterns.
@@ -137,4 +140,4 @@ In the future, we may use [incremental sync rule reprocessing](https://roadmap.p
137
140
138
141
## Technical details
139
142
140
-
See the [documentation](https://github.com/powersync-ja/powersync-service/blob/main/docs/compacting-operations.md) in the `powersync-service` repo for more technical details on compacting.
143
+
See the [documentation](https://github.com/powersync-ja/powersync-service/blob/main/docs/compacting-operations.md) in the `powersync-service` repo for more technical details on compacting.
0 commit comments