mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Ability to advance replication slots
Ability to advance both physical and logical replication slots using a new user function pg_replication_slot_advance(). For logical advance that means records are consumed as fast as possible and changes are not given to output plugin for sending. Makes 2nd phase (after we reached SNAPBUILD_FULL_SNAPSHOT) of replication slot creation faster, especially when there are big transactions as the reorder buffer does not have to deal with data changes and does not have to spill to disk. Author: Petr Jelinek Reviewed-by: Simon Riggs
This commit is contained in:
@ -45,6 +45,21 @@ INSERT INTO replication_example(somedata, text) VALUES (1, 3);
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot1', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot2', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
INSERT INTO replication_example(somedata, text) VALUES (1, 4);
|
||||
INSERT INTO replication_example(somedata, text) VALUES (1, 5);
|
||||
|
||||
SELECT pg_current_wal_lsn() AS wal_lsn \gset
|
||||
|
||||
INSERT INTO replication_example(somedata, text) VALUES (1, 6);
|
||||
|
||||
SELECT end_lsn FROM pg_replication_slot_advance('regression_slot1', :'wal_lsn') \gset
|
||||
SELECT slot_name FROM pg_replication_slot_advance('regression_slot2', pg_current_wal_lsn());
|
||||
|
||||
SELECT :'wal_lsn' = :'end_lsn';
|
||||
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot1', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot2', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
DROP TABLE replication_example;
|
||||
|
||||
-- error
|
||||
|
Reference in New Issue
Block a user