Once logical replication is enabled, the next step is to create a publication with the tables that you want to replicate to Materialize. You'll also need a user for Materialize with sufficient privileges to manage replication. 1. For each table that you want to replicate to Materialize, set the [replica identity](https://www.postgresql.org/docs/current/sql-altertable.html#SQL-ALTERTABLE-REPLICA-IDENTITY) to `FULL`: ```postgres ALTER TABLE REPLICA IDENTITY FULL; ``` ```postgres ALTER TABLE REPLICA IDENTITY FULL; ``` `REPLICA IDENTITY FULL` ensures that the replication stream includes the previous data of changed rows, in the case of `UPDATE` and `DELETE` operations. This setting enables Materialize to ingest PostgreSQL data with minimal in-memory state. However, you should expect increased disk usage in your PostgreSQL database. 1. Create a [publication](https://www.postgresql.org/docs/current/logical-replication-publication.html) with the tables you want to replicate: _For specific tables:_ ```postgres CREATE PUBLICATION mz_source FOR TABLE , ; ``` _For all tables in the database:_ ```postgres CREATE PUBLICATION mz_source FOR ALL TABLES; ``` The `mz_source` publication will contain the set of change events generated from the specified tables, and will later be used to ingest the replication stream. Be sure to include only the tables you need. If the publication includes additional tables, Materialize will waste resources on ingesting and then immediately discarding the data. 1. Create a user for Materialize, if you don't already have one: ```postgres CREATE USER materialize PASSWORD ''; ``` 1. Grant the user permission to manage replication: ```postgres ALTER ROLE materialize WITH REPLICATION; ``` 1. Grant the user the required permissions on the tables you want to replicate: ```postgres GRANT CONNECT ON DATABASE TO materialize; ``` ```postgres GRANT USAGE ON SCHEMA TO materialize; ``` ```postgres GRANT SELECT ON TO materialize; ``` ```postgres GRANT SELECT ON TO materialize; ``` Once connected to your database, Materialize will take an initial snapshot of the tables in your publication. `SELECT` privileges are required for this initial snapshot. If you expect to add tables to your publication, you can grant `SELECT` on all tables in the schema instead of naming the specific tables: ```postgres GRANT SELECT ON ALL TABLES IN SCHEMA TO materialize; ```