Skip to content

Commit 009f375

Browse files
docs: address review feedback on MySQL snapshot parallelism
Mark the table-splitting feature as private preview since it ships flag-off, restructure the shared parallelism include as a per-source list and caveat that a larger cluster can shorten the snapshot only as far as the work parallelizes, scope the troubleshooting connection guidance per source type, rework the overload mitigations around upsizing the database or dropping the source and retrying, point observability at the existing monitoring page, and add discovery blurbs to the MySQL and PostgreSQL ingest overview pages. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016AgSuGEvoVT9TFHAgq6FCi
1 parent eb40d6d commit 009f375

6 files changed

Lines changed: 90 additions & 54 deletions

File tree

doc/user/content/concepts/snapshotting.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ menu:
3131
Snapshotting has the following upstream impacts:
3232

3333
- **Read load.** Snapshotting puts read, CPU, and network load on the upstream
34-
system, proportional to the data volume and concentrated in proportion to
35-
the source cluster's [parallelism](#parallelism).
34+
system. The total load is proportional to the volume of data being
35+
snapshotted, while the source cluster's [parallelism](#parallelism) affects
36+
the peak load: more workers compress the reads into a shorter window.
3637

3738
- **Change-log retention for CDC database sources.** When ingesting data from
3839
CDC database sources (PostgreSQL, MySQL, SQL Server), the upstream system must

doc/user/content/headless/ingestion/snapshotting-parallelism.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,33 @@
22
headless: true
33
---
44

5-
Materialize parallelizes snapshotting across the workers of the cluster
6-
hosting the source. For PostgreSQL and MySQL sources, work is distributed by
7-
table, with different tables read concurrently by different workers.
8-
PostgreSQL sources additionally partition every table, splitting its read
9-
across workers (on PostgreSQL 14 and later). MySQL sources partition tables
10-
that meet certain requirements. See [MySQL snapshot
11-
parallelism](/ingest-data/mysql/snapshot-parallelism/). Kafka sources are
12-
parallelized by topic partition, with partitions distributed across workers,
13-
so parallelism is bounded by the topic's partition count. SQL Server sources
14-
are not parallelized: a single worker reads all tables.
5+
Materialize can parallelize snapshotting across the workers of the cluster
6+
hosting the source.
157

16-
A cluster's [size](/sql/create-cluster/#available-sizes) determines its
17-
number of workers, so a larger cluster shortens the snapshot. The volume
18-
read from the upstream database is unchanged, it is compressed into a
19-
shorter window of more concurrent queries and connections. To tell whether
20-
the upstream database is struggling under this load, and for options if it
21-
is, see [Is the upstream database
8+
- **PostgreSQL sources** are parallelized by table, i.e., different tables
9+
are read concurrently by different workers. On PostgreSQL 14 and later,
10+
Materialize additionally attempts to partition each table's read across
11+
workers. Tables that cannot be partitioned fall back to a single worker.
12+
13+
- **MySQL sources** are parallelized by table, i.e., different tables are
14+
read concurrently by different workers. For tables that meet certain
15+
requirements, Materialize can additionally partition the table's read
16+
across workers {{< private-preview-inline />}}. See [MySQL snapshot
17+
parallelism](/ingest-data/mysql/snapshot-parallelism/).
18+
19+
- **Kafka sources** are parallelized by topic partition, with partitions
20+
distributed across workers, so parallelism is bounded by the topic's
21+
partition count.
22+
23+
- **SQL Server sources** are not parallelized: a single worker reads all
24+
tables.
25+
26+
The degree of snapshot parallelism depends on the number of workers. A
27+
cluster's [size](/sql/create-cluster/#available-sizes) determines its number
28+
of workers, so a larger cluster can shorten the snapshot, to the extent the
29+
work parallelizes and the upstream database keeps up. The volume read from
30+
the upstream database is unchanged, it is compressed into a shorter window
31+
of more concurrent queries and connections. To determine whether
32+
snapshotting is overloading the upstream database, and for ways to mitigate
33+
the load, see [Is the upstream database
2234
overloaded?](/ingest-data/troubleshooting/#is-the-upstream-database-overloaded)

doc/user/content/ingest-data/mysql/_index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ gives you the following benefits:
3333
read-replica to build views on top of your MySQL data that are efficiently
3434
maintained and always up-to-date.
3535

36+
When a source is created, Materialize parallelizes the initial snapshot
37+
across the cluster's workers and can split the read of large tables that meet
38+
certain requirements {{< private-preview-inline />}}. See [Snapshot
39+
parallelism](/ingest-data/mysql/snapshot-parallelism/).
40+
3641
## Supported versions and services
3742

3843
{{< note >}}

doc/user/content/ingest-data/mysql/snapshot-parallelism.md

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,25 @@ menu:
99
weight: 70
1010
---
1111

12+
{{< private-preview />}}
13+
1214
When you create a [MySQL source](/sql/create-source/mysql-v2/), Materialize
1315
performs an initial, snapshot-based sync of the selected tables before it
1416
starts ingesting change events from the binlog. For large tables, this
1517
snapshot dominates the time until the source becomes healthy.
1618

1719
How snapshot work is spread across the workers of a cluster, and what that
1820
means for the upstream database, is covered in
19-
[Snapshotting](/concepts/snapshotting/#parallelism). This page covers what is
20-
specific to MySQL: Materialize can split the read of a **single table**
21-
across all the workers of the cluster, so that even a source dominated by one
22-
very large table benefits from a larger cluster.
21+
[Snapshotting](/concepts/snapshotting/#parallelism). Materialize can split
22+
the read of a **single table** across all the workers of the cluster, so
23+
that even a source dominated by one very large table benefits from a larger
24+
cluster. This page covers what is specific to MySQL: which tables are
25+
eligible for splitting, and how their reads are partitioned.
2326

2427
## Which tables are split
2528

26-
The snapshot of an individual table is split across workers when all of the
27-
following hold:
29+
Materialize splits the snapshot of an individual table across workers when
30+
all of the following conditions are met:
2831

2932
- The table has a **single-column primary key**. Composite primary keys are
3033
not supported.
@@ -39,19 +42,22 @@ following hold:
3942
How evenly the split lands also depends on the distribution of the key
4043
values. See [How a table is partitioned](#how-a-table-is-partitioned).
4144

42-
Tables that don't meet these requirements, or whose boundary sampling fails
43-
for any reason, still snapshot correctly: each is read in full by a single
44-
worker, and different tables are still read concurrently.
45+
If a table does not meet these requirements, or if the [boundary
46+
sampling](#how-a-table-is-partitioned) fails, its snapshot is not split: a
47+
single worker reads the table in full. Different tables are still read
48+
concurrently by different workers.
4549

4650
## How a table is partitioned
4751

48-
Materialize partitions a table by the unique leading characters of its
49-
primary keys. Before reading the table, it probes the primary key index to
50-
discover key prefixes and uses the MySQL optimizer's row estimates to gauge
51-
how many rows fall under each one, extending prefixes until it finds
52-
boundaries that divide the table into roughly even ranges. The probes are
53-
inexpensive point lookups, capped in proportion to the table's estimated
54-
size, so this sampling phase stays negligible next to the snapshot itself.
52+
Materialize partitions an [eligible](#which-tables-are-split) table using the
53+
leading characters of its primary key values. Before reading the table,
54+
Materialize probes the primary key index to discover key prefixes and uses
55+
the MySQL optimizer's row estimates to gauge how many rows fall under each
56+
prefix. It extends the prefixes as needed to find boundaries that divide the
57+
table into roughly even ranges. The probes are inexpensive point lookups,
58+
capped in proportion to the table's estimated size, so the sampling phase
59+
stays negligible next to the snapshot itself.
60+
5561
Each worker then reads only its assigned range, within the same consistent
5662
snapshot of the upstream database, so the result is identical to a
5763
single-worker snapshot, only faster.
@@ -97,8 +103,6 @@ overloaded?](/ingest-data/troubleshooting/#is-the-upstream-database-overloaded)
97103

98104
## Observability
99105

100-
The progress of an ongoing snapshot is visible in the
101-
[`mz_internal.mz_source_statistics`](/reference/system-catalog/mz_internal/#mz_source_statistics)
102-
system catalog view: `snapshot_records_known` is the estimated total size of
103-
the snapshot and `snapshot_records_staged` is how much of it has been read so
104-
far.
106+
To observe the progress of an ongoing snapshot, see [Monitoring the
107+
snapshotting
108+
progress](/ingest-data/monitoring-data-ingestion/#monitoring-the-snapshotting-progress).

doc/user/content/ingest-data/postgres/_index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ Materialize gives you the following benefits:
3737
Materialize as a read-replica to build views on top of your PostgreSQL data
3838
that are efficiently maintained and always up-to-date.
3939

40+
When a source is created, Materialize parallelizes the initial snapshot
41+
across the cluster's workers and, on PostgreSQL 14 and later, splits each
42+
table's read across workers. See [Snapshot
43+
parallelism](/concepts/snapshotting/#parallelism).
44+
4045
## Supported versions and services
4146

4247
The PostgreSQL source requires **PostgreSQL 11+** and is compatible with most

doc/user/content/ingest-data/troubleshooting.md

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,29 +101,38 @@ snapshotting](/ingest-data/#use-a-larger-cluster-for-upsert-source-snapshotting)
101101

102102
## Is the upstream database overloaded?
103103

104-
Snapshotting puts significant load on the upstream database (see [Impact on
105-
upstream system](/concepts/snapshotting/#impact-on-upstream-system)).
104+
Snapshotting can put significant load on the upstream database (see [Impact
105+
on upstream system](/concepts/snapshotting/#impact-on-upstream-system)).
106106

107-
Check the upstream database when a snapshot progresses more slowly than the
108-
data volume suggests, when applications sharing the database slow down while
107+
Check the upstream database when a snapshot progresses more slowly than
108+
expected, when applications sharing the database slow down while
109109
it runs, or when the source reports upstream connection errors or timeouts.
110110
The relevant metrics are in your cloud provider's monitoring console, or in
111111
OS tools like `iostat` and the database's activity views for self-hosted
112112
databases. Look for:
113113

114+
- **Read IOPS or throughput** flat at a provisioned cap.
114115
- **CPU** pinned at the instance's limit for the duration of the snapshot.
115-
- **Read IOPS or throughput** flat at a provisioned cap while disk queue
116-
depth and read latency climb.
117116
- **Network throughput** at the instance type's cap.
118-
- **Memory** pressure, or a falling cache hit rate as large scans evict the
119-
normal workload's working set.
120-
- **Connections** near the database's limit. Snapshotting opens connections
121-
in proportion to the source cluster's workers.
122-
123-
If the database is overloaded, snapshot during off-peak hours, ingest from a
124-
read replica, use a smaller source cluster to spread the load over a longer
125-
window, [limit the volume of data](/ingest-data/#limit-the-volume-of-data)
126-
you sync, or provision more IOPS, throughput, or instance capacity.
117+
- **Connections** near the database's limit. For PostgreSQL and MySQL
118+
sources, snapshotting opens connections in proportion to the source
119+
cluster's workers.
120+
121+
Also watch disk usage on the upstream database during a long-running
122+
snapshot: CDC database sources must retain their change log until Materialize
123+
consumes it (see [Impact on upstream
124+
system](/concepts/snapshotting/#impact-on-upstream-system)).
125+
126+
If the database is overloaded, you can upsize the source database or cancel
127+
the snapshot by dropping the source, and retry:
128+
129+
- on a smaller source cluster to spread the load over a longer window.
130+
- with more IOPS, throughput, or instance capacity provisioned for the
131+
database.
132+
- during off-peak hours when the database is less busy, as recommended in the
133+
[ingestion best practices](/ingest-data/#scheduling).
134+
- with a smaller [volume of data to
135+
sync](/ingest-data/#limit-the-volume-of-data).
127136

128137
## Adding a new subsource to an existing source blocks replication. Should I just create a new source instead?
129138

0 commit comments

Comments
 (0)