Setup
1. Create a materialized view to subscribe to
2. Create a subscription
3. Consume changes in Python
4. Consume with a start timestamp (resume from checkpoint)
Key points
- Change types:
'Insert','Delete','UpdateInsert'(new value after update),'UpdateDelete'(old value before update) retentioncontrols how far back you can start consuming (default: 24 hours)FETCH NEXT FROM cur WITH (timeout = 'Ns')blocks for up to N seconds waiting for data, then returns empty — eliminates the need for a polling sleep loop- A single subscription can have multiple cursors consuming independently
- Drop a subscription when no longer needed:
DROP SUBSCRIPTION high_value_alerts
Next steps
- Subscriptions reference — full API, cursor management, retention
- Kafka to MV recipe — set up the upstream pipeline