Disconnected from server. Attempting to reconnect...

Notify Mode vs Delta Mode

pg_reactive Example 11

Notify Mode

notify
Data may be stale — re-fetch to update
0
Events
0
Total Bytes

Delta Mode

delta
0
Events
0
Total Bytes

notify When to use

Use notify mode when you only need to know something changed and can re-fetch on demand. Ideal for dashboards with a refresh button, cache invalidation, or high-write tables where row-level diffs are too expensive.

delta When to use

Use delta mode when you need the exact rows that changed — inserted and deleted. Ideal for real-time UIs that animate individual row changes, collaborative editors, or when you need to maintain a client-side snapshot.

Demo Commands

Run these in psql: docker compose exec -T db psql -U postgres -d pg_reactive_test

-- Single reading (watch both panels)
INSERT INTO sensor_readings (sensor_id, temperature, humidity)
VALUES ('sensor-A', 24.5, 42.0);

-- Burst of 10 readings (notify panel: 10 tiny events, delta panel: 10 full diffs)
INSERT INTO sensor_readings (sensor_id, temperature, humidity)
SELECT
  'sensor-' || chr(65 + (i % 3)),
  20 + random() * 10,
  30 + random() * 40
FROM generate_series(1, 10) AS s(i);

-- Update (fires both invalidation and delta)
UPDATE sensor_readings
SET temperature = 99.9
WHERE sensor_id = 'sensor-C';
Subscribe API
-- Notify mode: ~50 bytes per event, no query re-execution
SELECT pgr.subscribe('my_query', 'SELECT ...', 'notify');

-- Delta mode (default): full row diffs, snapshot management
SELECT pgr.subscribe('my_query', 'SELECT ...', 'delta');
SELECT pgr.subscribe('my_query', 'SELECT ...'); -- same as 'delta'