<@U04S8PLJWMT> how can I store in a connection mys...
# ask-ai
f
@kapa.ai how can I store in a connection mysql source --> bigquery destination in CDC mode all rows on binlogs?
k
To store all rows from MySQL binlogs in a connection with a MySQL source and BigQuery destination using CDC mode in Airbyte, you need to: 1. Enable CDC (Change Data Capture) on the MySQL source: This requires enabling the MySQL binary log (binlog) and configuring it for row-based logging. Airbyte uses Debezium under the hood to read the binlog and capture all changes (inserts, updates, deletes) in near real-time. Make sure your MySQL server is configured with
binlog_format=ROW
and that binary logging is enabled (
log_bin=ON
) [MySQL CDC: Build an ELT pipeline from MySQL Database](https://airbyte.com/tutorials/mysql-change-data-capture-cdc). 2. Set up the Airbyte connection: - When creating the connection, select your MySQL source and BigQuery destination. - Choose the Incremental | Append sync mode. In CDC mode, this will ensure that only the changes captured in the binlog are synced to BigQuery. - You do not need to select a cursor field manually; Airbyte will use the CDC internal cursor managed by Debezium [Explore Airbyte's Change Data Capture (CDC) synchronization](https://airbyte.com/tutorials/incremental-change-data-capture-cdc-replication). 3. Run the sync: After saving the connection, trigger a sync. Airbyte will read all changes from the MySQL binlog and write them to BigQuery. All rows present in the binlog (i.e., all changes since the last sync or since CDC was enabled) will be replicated to the destination. Important notes: - The initial sync will perform a full snapshot of the source table(s), after which only changes from the binlog are replicated. - Ensure your MySQL binlog retention is set high enough so that binlogs are not purged before Airbyte can read them, especially for large tables or infrequent syncs. If binlogs are purged too soon, Airbyte may be forced to do a full refresh [Troubleshooting MySQL Sources](https://docs.airbyte.com/integrations/sources/mysql/mysql-troubleshooting#troubleshooting). - In CDC mode, Airbyte automatically manages the cursor and primary key selection; you do not need to configure these manually [Explore Airbyte's Change Data Capture (CDC) synchronization](https://airbyte.com/tutorials/incremental-change-data-capture-cdc-replication). If you follow these steps, all changes present in the MySQL binlogs will be captured and stored in your BigQuery destination via Airbyte's CDC pipeline.
f
@kapa.ai this meand that "+DEDUPED" use MERGE on destination bigquery and NOT DEDUPED insert rows on destination?
k
A message from kapa.ai
In Airbyte, the +DEDUPED sync modes (such as "Incremental Append + Deduped" or "Full Refresh Overwrite + Deduped") ensure that the final table in the destination (e.g., BigQuery) contains only one row per primary key. This is achieved by de-duplicating the data using the primary key and the cursor field, keeping only the latest version of each record. The documentation describes this as sorting the data using the cursor field and keeping only the latest de-duplicated data row [Incremental Sync - Append + Deduped](https://docs.airbyte.com/platform/using-airbyte/core-concepts/sync-modes/incremental-append-deduped), [Full Refresh - Overwrite + Deduped](https://docs.airbyte.com/platform/using-airbyte/core-concepts/sync-modes/full-refresh-overwrite-deduped). On the other hand, the NOT DEDUPED (e.g., "Incremental Append") mode simply appends all new or updated records to the destination table, without removing duplicates. This means that if a record is updated multiple times, multiple versions of that record will exist in the destination table [What is incremental synchronization](https://airbyte.com/tutorials/incremental-data-synchronization#step-2). The documentation does not explicitly state that Airbyte uses the SQL
MERGE
statement in BigQuery for deduplication, but it does clarify that deduplication is performed so that only the latest record per primary key is present in the final table. The actual implementation may vary by destination, but the key difference is: - +DEDUPED: The final table is deduplicated (one row per primary key, latest version). - NOT DEDUPED: All rows are inserted, including duplicates and historical versions. If you need strict deduplication in BigQuery, use the +DEDUPED mode. If you want to keep all historical changes, use the NOT DEDUPED mode. > "The deduped variant also means that the data in the final table will be unique per primary key... This is determined by sorting the data using the cursor field and keeping only the latest de-duplicated data row." [Full Refresh - Overwrite + Deduped](https://docs.airbyte.com/platform/using-airbyte/core-concepts/sync-modes/full-refresh-overwrite-deduped) > "In the data warehouse, just like in incremental - Append, multiple rows for the same primary key can be found in the history table. The unique records per primary key behavior is mirrored in the final table with incremental deduped sync mode." [Incremental Sync - Append + Deduped](https://docs.airbyte.com/platform/using-airbyte/core-concepts/sync-modes/incremental-append-deduped)