<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Quayen</title>
    <description>The latest articles on DEV Community by Quayen (@quayen_support).</description>
    <link>https://dev.to/quayen_support</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4234696%2F0e6bf9a2-58d3-4e06-ac38-8b07e4c896b5.png</url>
      <title>DEV Community: Quayen</title>
      <link>https://dev.to/quayen_support</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/quayen_support"/>
    <language>en</language>
    <item>
      <title>Google Cloud Datastream pricing explained, with examples</title>
      <dc:creator>Quayen</dc:creator>
      <pubDate>Fri, 20 Nov 2026 13:00:36 +0000</pubDate>
      <link>https://dev.to/quayen_support/google-cloud-datastream-pricing-explained-with-examples-e84</link>
      <guid>https://dev.to/quayen_support/google-cloud-datastream-pricing-explained-with-examples-e84</guid>
      <description>&lt;p&gt;Google Cloud Datastream charges for data processed, not for running streams: an idle stream costs nothing. The catch is how "processed" is measured. Google notes that a processed byte is an internal representation of the source data, and for most workloads it is &lt;strong&gt;2 to 5 times larger&lt;/strong&gt; than the data itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  CDC prices (USD, November 2026)
&lt;/h2&gt;

&lt;p&gt;Tiered per billing account per month; each price applies only to the GiB inside its tier:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Monthly CDC volume&lt;/th&gt;
&lt;th&gt;Price per GiB&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0 – 2,500 GiB&lt;/td&gt;
&lt;td&gt;$2.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2,500 – 5,000 GiB&lt;/td&gt;
&lt;td&gt;$1.50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5,000 – 10,000 GiB&lt;/td&gt;
&lt;td&gt;$1.20&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10,000+ GiB&lt;/td&gt;
&lt;td&gt;$0.80 (contact sales beyond 10 TB)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Backfill
&lt;/h2&gt;

&lt;p&gt;The initial snapshot is billed at a flat per-GiB rate, with the first 500 GiB each month free. Re-running a backfill counts again.&lt;/p&gt;

&lt;h2&gt;
  
  
  The free tier doesn't cover MySQL
&lt;/h2&gt;

&lt;p&gt;Datastream's perpetual free tier (100 GiB of CDC a month) applies only to AlloyDB and Spanner sources. MySQL pays from the first GiB.&lt;/p&gt;

&lt;h2&gt;
  
  
  Worked examples (CDC only, 2×–5× processed bytes)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;5 GiB of row changes a month:&lt;/strong&gt; 10–25 GiB processed → about &lt;strong&gt;$20–$50/month&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;200 GiB a month:&lt;/strong&gt; 400–1,000 GiB → about &lt;strong&gt;$800–$2,000/month&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;1 TiB a month:&lt;/strong&gt; 2,048–5,120 GiB → about &lt;strong&gt;$4,100–$8,900/month&lt;/strong&gt; after tier discounts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;BigQuery storage and the compute that applies changes are billed separately.&lt;/p&gt;

&lt;h2&gt;
  
  
  Estimate your change volume
&lt;/h2&gt;

&lt;p&gt;Run &lt;code&gt;SHOW BINARY LOGS;&lt;/code&gt; on the primary at the same time on two days and add up &lt;code&gt;File_size&lt;/code&gt; for the files created in between: roughly one day of changes. Multiply by 30.&lt;/p&gt;

&lt;h2&gt;
  
  
  Per-GiB vs per-row
&lt;/h2&gt;

&lt;p&gt;Per-GiB pricing grows with row width: wide JSON or text columns cost more per change. Per-row pricing (monthly active rows) doesn't care how wide the row is.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: I work on &lt;a href="https://quayen.com" rel="noopener noreferrer"&gt;Quayen&lt;/a&gt;, which prices MySQL-to-BigQuery CDC per row. Original article with links: &lt;a href="https://quayen.com/docs/google-cloud-datastream-pricing" rel="noopener noreferrer"&gt;quayen.com/docs/google-cloud-datastream-pricing&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>googlecloud</category>
      <category>bigquery</category>
      <category>mysql</category>
      <category>dataengineering</category>
    </item>
    <item>
      <title>BigQuery vs MySQL: differences and when to use each</title>
      <dc:creator>Quayen</dc:creator>
      <pubDate>Fri, 20 Nov 2026 12:52:17 +0000</pubDate>
      <link>https://dev.to/quayen_support/bigquery-vs-mysql-differences-and-when-to-use-each-18ga</link>
      <guid>https://dev.to/quayen_support/bigquery-vs-mysql-differences-and-when-to-use-each-18ga</guid>
      <description>&lt;p&gt;MySQL and BigQuery both speak SQL, but they are built for opposite jobs. MySQL runs your application: many small reads and writes, each in milliseconds. BigQuery answers questions about all of your data at once: fewer, larger queries over millions or billions of rows.&lt;/p&gt;

&lt;h2&gt;
  
  
  The main differences
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Workload:&lt;/strong&gt; MySQL is transactional (OLTP); BigQuery is an analytical (OLAP) warehouse.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage:&lt;/strong&gt; InnoDB stores whole rows and uses indexes to find a few quickly. BigQuery stores each column separately and compressed, so a query reads only the columns it needs, across every row.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Speed:&lt;/strong&gt; a primary-key lookup in MySQL takes well under a millisecond, but a &lt;code&gt;GROUP BY&lt;/code&gt; over a big table can take minutes and slow the app. A BigQuery query rarely takes less than a second, but aggregates billions of rows in seconds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transactions and updates:&lt;/strong&gt; MySQL handles thousands of concurrent single-row writes with ACID transactions. BigQuery supports &lt;code&gt;UPDATE&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt; and &lt;code&gt;MERGE&lt;/code&gt;, but is designed for bulk changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; MySQL costs what the server costs, busy or idle. BigQuery charges for storage plus bytes scanned (or reserved compute), so partitioning and clustering matter.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operations:&lt;/strong&gt; MySQL scales up and out with replicas; BigQuery is serverless.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dialect:&lt;/strong&gt; &lt;code&gt;DATE_FORMAT&lt;/code&gt; becomes &lt;code&gt;FORMAT_DATETIME&lt;/code&gt;, &lt;code&gt;TIMESTAMPDIFF&lt;/code&gt; becomes &lt;code&gt;TIMESTAMP_DIFF&lt;/code&gt;, and BigQuery adds &lt;code&gt;STRUCT&lt;/code&gt; and &lt;code&gt;ARRAY&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When to use each
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MySQL:&lt;/strong&gt; the database behind your application (orders, users, payments).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;BigQuery:&lt;/strong&gt; reporting, dashboards, ad-hoc analysis, ML, joining app data with other sources.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why most teams use both
&lt;/h2&gt;

&lt;p&gt;Heavy reports on production MySQL slow the app, and a read replica only moves the problem. The usual setup keeps MySQL for the app and copies its data into BigQuery: nightly exports at first, then change data capture from the binary log when people need fresh numbers and deletes to match.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: I work on &lt;a href="https://quayen.com" rel="noopener noreferrer"&gt;Quayen&lt;/a&gt; (MySQL to BigQuery CDC). Original article: &lt;a href="https://quayen.com/docs/bigquery-vs-mysql" rel="noopener noreferrer"&gt;quayen.com/docs/bigquery-vs-mysql&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>bigquery</category>
      <category>mysql</category>
      <category>database</category>
      <category>sql</category>
    </item>
    <item>
      <title>How to connect MySQL to BigQuery: 5 ways, including real time</title>
      <dc:creator>Quayen</dc:creator>
      <pubDate>Fri, 20 Nov 2026 12:52:16 +0000</pubDate>
      <link>https://dev.to/quayen_support/how-to-connect-mysql-to-bigquery-5-ways-including-real-time-3nce</link>
      <guid>https://dev.to/quayen_support/how-to-connect-mysql-to-bigquery-5-ways-including-real-time-3nce</guid>
      <description>&lt;p&gt;There are five common ways to connect MySQL to BigQuery, whether you want a one-time migration or a copy that stays in sync. They differ mostly in how fresh the data is, whether deletes come through, and how much you have to run yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Scheduled exports
&lt;/h2&gt;

&lt;p&gt;A nightly dump or &lt;code&gt;SELECT ... INTO OUTFILE&lt;/code&gt;, then a BigQuery load job. Simple and cheap, but data is up to a day old, every run re-reads whole tables, and deletes only show up if you reload everything.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Incremental queries on &lt;code&gt;updated_at&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Fresher, but they miss deletes and any update that doesn't touch &lt;code&gt;updated_at&lt;/code&gt;, and they put query load on MySQL.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Federated queries (Cloud SQL only)
&lt;/h2&gt;

&lt;p&gt;BigQuery's &lt;code&gt;EXTERNAL_QUERY&lt;/code&gt; reads Cloud SQL live with no copy at all, but every query hits your production database and nothing is stored in BigQuery.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Self-managed CDC
&lt;/h2&gt;

&lt;p&gt;Debezium, Kafka and a BigQuery sink. Real time and flexible, but you operate several services and the merge logic for updates and deletes yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Managed log-based CDC
&lt;/h2&gt;

&lt;p&gt;Google Cloud Datastream, Fivetran, Airbyte, Hevo, Estuary, Quayen and others read MySQL's binary log, so deletes are included and the load on MySQL is close to a replica's. How quickly changes become queryable depends on the tool and plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why log-based CDC is the usual answer
&lt;/h2&gt;

&lt;p&gt;MySQL already records every insert, update and delete in its binary log for replicas. Reading that log captures changes exactly once and in order, including deletes, without querying your tables. You need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="no"&gt;SHOW&lt;/span&gt; &lt;span class="no"&gt;VARIABLES&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="nc"&gt;Variable_name&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'log_bin'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'binlog_format'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'binlog_row_image'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;-- want: log_bin=ON, binlog_format=ROW, binlog_row_image=FULL&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and a user with &lt;code&gt;SELECT&lt;/code&gt;, &lt;code&gt;REPLICATION SLAVE&lt;/code&gt; and &lt;code&gt;REPLICATION CLIENT&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which to pick
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;One-off migration: export + &lt;code&gt;bq load&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Dashboards that can be a day old: scheduled exports.&lt;/li&gt;
&lt;li&gt;Anything that must match the app (status, deletes, cancellations): log-based CDC.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Disclosure: I work on &lt;a href="https://quayen.com" rel="noopener noreferrer"&gt;Quayen&lt;/a&gt;, a managed MySQL-to-BigQuery CDC service. The full guide, with per-host setup steps, is &lt;a href="https://quayen.com/docs/mysql-to-bigquery-real-time" rel="noopener noreferrer"&gt;on our site&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>bigquery</category>
      <category>dataengineering</category>
      <category>database</category>
    </item>
    <item>
      <title>Streaming MySQL to BigQuery with the binlog: how CDC works, and the parts that bite</title>
      <dc:creator>Quayen</dc:creator>
      <pubDate>Mon, 09 Nov 2026 08:12:40 +0000</pubDate>
      <link>https://dev.to/quayen_support/streaming-mysql-to-bigquery-with-the-binlog-how-cdc-works-and-the-parts-that-bite-40jl</link>
      <guid>https://dev.to/quayen_support/streaming-mysql-to-bigquery-with-the-binlog-how-cdc-works-and-the-parts-that-bite-40jl</guid>
      <description>&lt;p&gt;Most teams start syncing MySQL to BigQuery with a nightly dump or a query like &lt;code&gt;SELECT * FROM orders WHERE updated_at &amp;gt; :last_run&lt;/code&gt;. It works until someone asks why deleted orders still show up in the dashboard, or why yesterday's numbers changed. This post walks through how log-based change data capture (CDC) from MySQL to BigQuery works end to end, and the details that decide whether it's correct and affordable.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: I build &lt;a href="https://quayen.com" rel="noopener noreferrer"&gt;Quayen&lt;/a&gt;, a managed MySQL to BigQuery CDC service. Everything here applies whether you build this yourself with Debezium or use any managed tool.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why polling isn't enough
&lt;/h2&gt;

&lt;p&gt;Query-based syncs on an &lt;code&gt;updated_at&lt;/code&gt; column have three structural problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deletes are invisible.&lt;/strong&gt; A deleted row has no &lt;code&gt;updated_at&lt;/code&gt;; it's simply gone, so the query never returns it and BigQuery keeps it forever.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Not every write touches &lt;code&gt;updated_at&lt;/code&gt;.&lt;/strong&gt; Bulk updates, migrations and some ORMs skip it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;They load production.&lt;/strong&gt; Every run scans an index on your busiest tables.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;MySQL already records every committed change, including deletes, in its &lt;strong&gt;binary log&lt;/strong&gt; so replicas can follow along. Reading that log is what log-based CDC does.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: configure the binlog
&lt;/h2&gt;

&lt;p&gt;CDC needs three settings, plus enough retention:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SHOW&lt;/span&gt; &lt;span class="k"&gt;GLOBAL&lt;/span&gt; &lt;span class="n"&gt;VARIABLES&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;Variable_name&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'log_bin'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'binlog_format'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'binlog_row_image'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'binlog_expire_logs_seconds'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;log_bin = ON&lt;/code&gt;. On RDS this means automated backups must be on; on Cloud SQL it's point-in-time recovery.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;binlog_format = ROW&lt;/code&gt;. &lt;code&gt;STATEMENT&lt;/code&gt; logs the SQL text, not the resulting row values, so a CDC reader can't know what changed. &lt;code&gt;MIXED&lt;/code&gt; falls back to statements most of the time.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;binlog_row_image = FULL&lt;/code&gt;. &lt;code&gt;MINIMAL&lt;/code&gt; logs only changed columns, so your BigQuery rows end up with holes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retention of at least 3 days.&lt;/strong&gt; If the pipeline stops and MySQL purges logs it hasn't read, you get &lt;code&gt;error 1236: Could not find first log file name in binary log index file&lt;/code&gt; and have to re-copy everything. On RDS and Aurora, retention is &lt;code&gt;CALL mysql.rds_set_configuration('binlog retention hours', 72);&lt;/code&gt;, not &lt;code&gt;binlog_expire_logs_seconds&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The replication user needs &lt;code&gt;SELECT&lt;/code&gt; on your schema plus &lt;code&gt;REPLICATION SLAVE&lt;/code&gt; and &lt;code&gt;REPLICATION CLIENT&lt;/code&gt; on &lt;code&gt;*.*&lt;/code&gt;. Nothing else. (If you want to check a server quickly, I made a &lt;a href="https://quayen.com/tools/mysql-binlog-cdc-checker" rel="noopener noreferrer"&gt;free binlog checker&lt;/a&gt; that reads the output of the query above.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: snapshot, then stream from the exact position
&lt;/h2&gt;

&lt;p&gt;Existing rows aren't in the binlog (it's been purged long ago), so a pipeline starts with a snapshot:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open a consistent snapshot (&lt;code&gt;START TRANSACTION WITH CONSISTENT SNAPSHOT&lt;/code&gt;) and record the binlog position (file + offset, or GTID set) at that same moment.&lt;/li&gt;
&lt;li&gt;Copy every row of the selected tables into BigQuery.&lt;/li&gt;
&lt;li&gt;Start reading the binlog &lt;strong&gt;from the recorded position&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Changes that happen during a long copy aren't lost: they're in the binlog after the recorded position and are applied afterwards. The ordering rule below makes it safe if a change touches a row that the snapshot already copied.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: land changes in an append-only change log
&lt;/h2&gt;

&lt;p&gt;Don't try to &lt;code&gt;UPDATE&lt;/code&gt; BigQuery row by row as events arrive. BigQuery is built for appends and big set-based statements, and DML quotas will stop you. Instead, append every event to a change-log table:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;column&lt;/th&gt;
&lt;th&gt;meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_op&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;c&lt;/code&gt; insert, &lt;code&gt;u&lt;/code&gt; update, &lt;code&gt;d&lt;/code&gt; delete&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;_seq&lt;/code&gt;, &lt;code&gt;_row&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;binlog position of the event, and the row's index within it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_ingested_at&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;when it reached BigQuery&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;the table's columns&lt;/td&gt;
&lt;td&gt;the row values after the change (before, for deletes)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Appends via the Storage Write API land within seconds, and the change log is useful on its own: it's a full history of every row ("what was this order's status last Tuesday?").&lt;/p&gt;

&lt;p&gt;Two details matter here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Only save your read position after BigQuery has accepted the batch.&lt;/strong&gt; Then a crash replays a few events instead of losing them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replays must be harmless.&lt;/strong&gt; That's what &lt;code&gt;_seq&lt;/code&gt; is for.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 4: merge into an up-to-date table
&lt;/h2&gt;

&lt;p&gt;Analysts want a table that looks like MySQL, not an event log. On a schedule, apply the new changes with a &lt;code&gt;MERGE&lt;/code&gt;, keeping only the latest change per primary key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;MERGE&lt;/span&gt; &lt;span class="nv"&gt;`analytics.orders`&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;
&lt;span class="k"&gt;USING&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;EXCEPT&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ROW_NUMBER&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="n"&gt;OVER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;PARTITION&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;_seq&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_row&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;rn&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="nv"&gt;`analytics_changelog.orders`&lt;/span&gt;
    &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;_seq&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;last_applied_seq&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;rn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;
&lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;MATCHED&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_op&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'d'&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_seq&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_seq&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="k"&gt;DELETE&lt;/span&gt;
&lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;MATCHED&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_seq&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_seq&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
  &lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_seq&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_seq&lt;/span&gt;
&lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="n"&gt;MATCHED&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_op&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s1"&gt;'d'&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
  &lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_seq&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_seq&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ordering by binlog position (not by arrival time) means applying the same batch twice, or overlapping batches, can't produce a wrong row. The &lt;code&gt;s._seq &amp;gt; t._seq&lt;/code&gt; guard protects rows the snapshot copied after a change was already applied.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: handle schema changes and the ugly types
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;New columns:&lt;/strong&gt; when MySQL gains a column, add it to both BigQuery tables before applying events that contain it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Type mapping:&lt;/strong&gt; &lt;code&gt;BIGINT UNSIGNED&lt;/code&gt; doesn't fit &lt;code&gt;INT64&lt;/code&gt; (use &lt;code&gt;NUMERIC&lt;/code&gt;), wide &lt;code&gt;DECIMAL&lt;/code&gt;s need &lt;code&gt;BIGNUMERIC&lt;/code&gt;, &lt;code&gt;TIME&lt;/code&gt; can exceed 24 hours so store it as &lt;code&gt;STRING&lt;/code&gt;, and &lt;code&gt;TINYINT(1)&lt;/code&gt; is MySQL's boolean. (&lt;a href="https://quayen.com/tools/mysql-to-bigquery-schema-converter" rel="noopener noreferrer"&gt;Free converter&lt;/a&gt; that applies these rules to a &lt;code&gt;CREATE TABLE&lt;/code&gt;.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Primary keys are mandatory.&lt;/strong&gt; Without one there's no way to match an update or delete to a row.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The part that surprises people: BigQuery cost
&lt;/h2&gt;

&lt;p&gt;With on-demand pricing, a &lt;code&gt;MERGE&lt;/code&gt; that updates or deletes rows is billed for the whole target table it scans (or the partitions it touches). Refresh a 200 GiB table every 5 minutes and that's hundreds of TiB a month. The fixes: refresh less often, partition by a column that's set once (like &lt;code&gt;created_at&lt;/code&gt;), use insert-only merges when a batch has no updates or deletes, and skip tables with no new changes. I wrote up the numbers in a separate post.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build or buy
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Debezium + Kafka + a BigQuery sink:&lt;/strong&gt; flexible and open source, but you operate Kafka Connect, schema history, and write the merge logic above yourself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google Cloud Datastream:&lt;/strong&gt; serverless and inside your GCP project, priced per GiB processed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fivetran, Airbyte, Hevo, Estuary:&lt;/strong&gt; broad connector platforms; check how often they actually merge into BigQuery and how they meter volume.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://quayen.com" rel="noopener noreferrer"&gt;Quayen&lt;/a&gt;:&lt;/strong&gt; does only MySQL to BigQuery, with the snapshot, change log, ordered merges and cost controls above built in.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Whichever you choose, check these four things: deletes are removed (not just flagged), changes are ordered by log position, the read position is saved only after BigQuery accepts a batch, and you know what each refresh costs.&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>bigquery</category>
      <category>dataengineering</category>
      <category>database</category>
    </item>
  </channel>
</rss>
