> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://apidocs.polytomic.com/2023-04-25/configuring-your-connections/cdc-streaming-from-databases/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://apidocs.polytomic.com/_mcp/server. When syncing untransformed data from PostgreSQL or MySQL into a data warehouse, database, or cloud storage, it's preferred (though not required) for Polytomic to utilize CDC (change data capture) replication. This will avoid Polytomic running table scans to figure out changes since the last sync. Rather, Polytomic will process changes in real-time without scanning source tables. This section covers setup instructions to enable this on PostgreSQL and MySQL. #### PostgreSQL ## PostgreSQL To enable CDC streaming from PostgreSQL, Polytomic requires the following of the PostgreSQL instance: * PostgreSQL 10 or later (Polytomic uses the `pgoutput` plugin). * Set the PostgreSQL `wal_level` setting to `logical`. You can determine the value of the `wal_level` setting by running this query: ``` my_database=> show wal_level; wal_level ----------- logical (1 row) ``` * Available replication slot. Polytomic requires a replication slot for each bulk sync; the same slot will be used for all tables synced as part of that bulk sync configuration. The total number of replication slots is set using the `max_replication_slots` PostgreSQL setting. You can inspect current replication slots using the `pg_replication_slots` system table: ``` select * from pg_replication_slots; ``` * User with `REPLICATION` property set. The `REPLICATION` property signals that a PostgreSQL user (role) is able to manage replication slots. Polytomic will use this property to create a replication slot for each bulk sync configured. You can set it with the following query: ``` ALTER ROLE polytomic_user WITH REPLICATION; ``` * A publication for the tables you wish to replicate. PostgreSQL uses a publication to track changes to one or more tables. Only a user with the owner role for a table may add it to the publication. After the publication is created, however, any user with the `REPLICATION` property may use it. You can create a publication for specific tables or for all tables (including those created in the future). Note that creating a publication for all tables may result in increased storage consumption. The publication name can be anything; you’ll enter it in Polytomic's PostgreSQL [connection configuration](https://apidocs.polytomic.com/configuring-your-connections/connection-configurations#postgresql). ``` -- Create a publication for specific tables CREATE PUBLICATION polytomic FOR TABLE ,
, ...; -- Create a publication for all current and future tables CREATE PUBLICATION polytomic FOR ALL TABLES; ``` ### Set your Polytomic PostgreSQL connection configuration Once the previous steps are done, be sure to set the following arguments in Polytomic's PostgreSQL [connection configuration](https://apidocs.polytomic.com/configuring-your-connections/connection-configurations#postgresql): * `change_detection`: `true` * `publication`: the name of the publication generated in the previous section #### MySQL ## MySQL To enable CDC streaming from MySQL, Polytomic requires the following of the PostgreSQL instance: * The Polytomic MySQL user needs to be configured with replication privileges. This can be done with the following query (replace `` with your MySQL user): ``` GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO @'%'; ``` For example, if your MySQL user is `polytomic` then your query would be: ``` GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO polytomic@'%'; ``` * Set the following settings on the MySQL database: * `binlog_format`: `ROW` * `binlog_row_image`: `full` * `binlog_row_metadata`: `FULL` * `slave_parallel_type`: `LOGICAL_CLOCK` The exact way to set these will depend on your MySQL hosting platform. If you're hosting MySQL yourself then you'll need to edit your `my.cnf file`, whereas if you're on AWS RDS you'll have to edit your parameter group as shown in this screenshot: ![MySQL](https://www-polytomic-assets.s3.us-west-2.amazonaws.com/api-docs/mysql-cdc-settings.png) * Set a log retention period of at least 1 day. We recommend 7 days. ### Set your Polytomic MySQL connection configuration Once the previous steps are done, be sure to set the following argument in Polytomic's MySQL [connection configuration](https://apidocs.polytomic.com/configuring-your-connections/connection-configurations#postgresql): * `change_detection`: `true`