File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,11 @@ const char *PROGRAM_VERSION = "unknown";
48
48
*/
49
49
#define APPLY_COUNT 1000
50
50
51
+ /* Once we get down to seeing fewer than this many tuples in the
52
+ * log table, we'll say that we're ready to perform the switch.
53
+ */
54
+ #define MIN_TUPLES_BEFORE_SWITCH 20
55
+
51
56
/* poll() or select() timeout, in seconds */
52
57
#define POLL_TIMEOUT 3
53
58
@@ -1305,7 +1310,16 @@ repack_one_table(repack_table *table, const char *orderby)
1305
1310
for (;;)
1306
1311
{
1307
1312
num = apply_log (connection , table , APPLY_COUNT );
1308
- if (num > 0 )
1313
+
1314
+ /* We'll keep applying tuples from the log table in batches
1315
+ * of APPLY_COUNT, until applying a batch of tuples
1316
+ * (via LIMIT) results in our having applied
1317
+ * MIN_TUPLES_BEFORE_SWITCH or fewer tuples. We don't want to
1318
+ * get stuck repetitively applying some small number of tuples
1319
+ * from the log table as inserts/updates/deletes may be
1320
+ * constantly coming into the original table.
1321
+ */
1322
+ if (num > MIN_TUPLES_BEFORE_SWITCH )
1309
1323
continue ; /* there might be still some tuples, repeat. */
1310
1324
1311
1325
/* old transactions still alive ? */
You can’t perform that action at this time.
0 commit comments