1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
-- like bt_index_check('pglogical.sequence_state', true)
CREATE FUNCTION heapallindexed() RETURNS void AS $$
DECLARE
count_seqscan int;
count_idxscan int;
BEGIN
count_seqscan := (SELECT count(*) FROM pglogical.sequence_state);
SET enable_seqscan = off;
count_idxscan := (SELECT count(*) FROM pglogical.sequence_state);
RESET enable_seqscan;
IF count_seqscan <> count_idxscan THEN
RAISE 'seqscan found % rows, but idxscan found % rows',
count_seqscan, count_idxscan;
END IF;
END
$$ LANGUAGE plpgsql;
-- Replicate one sequence.
CREATE SEQUENCE stress;
SELECT * FROM pglogical.create_replication_set('stress_seq');
create_replication_set
------------------------
2261733486
(1 row)
SELECT * FROM pglogical.replication_set_add_sequence('stress_seq', 'stress');
replication_set_add_sequence
------------------------------
t
(1 row)
SELECT pglogical.synchronize_sequence('stress');
synchronize_sequence
----------------------
t
(1 row)
SELECT heapallindexed();
heapallindexed
----------------
(1 row)
-- Sync it 400 times in one transaction, to cross a pglogical.sequence_state
-- page boundary and get a non-HOT update.
DO $$
BEGIN
FOR i IN 1..400 LOOP
PERFORM pglogical.synchronize_sequence('stress');
END LOOP;
END;
$$;
SELECT heapallindexed();
heapallindexed
----------------
(1 row)
|