You can use Debezium to propagate Change Data Capture (CDC) data from a database to Materialize, for example MySQL or PostgreSQL.
Debezium emits records using an envelope that contains valuable information about the change captured, like the
after values for each record. This envelope is a powerful structure that lets Materialize perform more complex analysis to understand all CRUD-like operations happening in the upstream database. For more details on CDC support in Materialize, check the documentation.
For the best CDC experience, we recommend following the guidelines in the Debezium documentation for each upstream database:
|MySQL||Debezium MySQL Connector|
|PostgreSQL||Debezium PostgreSQL Connector|
As an example, for Debezium to emit the envelope Materialize expects when using PostgreSQL, the tables selected for CDC must have the parameter
REPLICA IDENTITY FULL set:
ALTER TABLE foo REPLICA IDENTITY FULL;
If you need to connect Materialize to a PostgreSQL database but Kafka is not part of your stack, you can use the PostgreSQL direct source. This source uses PostgreSQL’s native replication protocol to continuously propagate upstream changes into Materialize, bypassing the need to deploy and maintain a Kafka instance. For more details and step-by-step instructions, check the documentation.