12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- After the snapshotting phase, Materialize starts ingesting change events from
- the PostgreSQL replication stream. For this work, Materialize generally
- performs well with an `100cc` replica, so you can resize the cluster
- accordingly.
- 1. Still in a SQL client connected to Materialize, use the [`ALTER CLUSTER`](/sql/alter-cluster/)
- command to downsize the cluster to `100cc`:
- ```mzsql
- ALTER CLUSTER ingest_postgres SET (SIZE '100cc');
- ```
- Behind the scenes, this command adds a new `100cc` replica and removes the
- `50cc` replica.
- 1. Use the [`SHOW CLUSTER REPLICAS`](/sql/show-cluster-replicas/) command to
- check the status of the new replica:
- ```mzsql
- SHOW CLUSTER REPLICAS WHERE cluster = 'ingest_postgres';
- ```
- <p></p>
- ```nofmt
- cluster | replica | size | ready
- -----------------+---------+--------+-------
- ingest_postgres | r1 | 100cc | t
- (1 row)
- ```
- 1. Going forward, you can verify that your new cluster size is sufficient as
- follows:
- 1. In Materialize, get the replication slot name associated with your
- PostgreSQL source from the [`mz_internal.mz_postgres_sources`](/sql/system-catalog/mz_internal/#mz_postgres_sources)
- table:
- ```mzsql
- SELECT
- d.name AS database_name,
- n.name AS schema_name,
- s.name AS source_name,
- pgs.replication_slot
- FROM
- mz_sources AS s
- JOIN mz_internal.mz_postgres_sources AS pgs ON s.id = pgs.id
- JOIN mz_schemas AS n ON n.id = s.schema_id
- JOIN mz_databases AS d ON d.id = n.database_id;
- ```
- 1. In PostgreSQL, check the replication slot lag, using the replication slot
- name from the previous step:
- ```postgres
- SELECT
- pg_size_pretty(pg_current_wal_lsn() - confirmed_flush_lsn)
- AS replication_lag_bytes
- FROM pg_replication_slots
- WHERE slot_name = '<slot_name>';
- ```
- The result of this query is the amount of data your PostgreSQL cluster
- must retain in its replication log because of this replication slot.
- Typically, this means Materialize has not yet communicated back to
- PostgreSQL that it has committed this data. A high value can indicate
- that the source has fallen behind and that you might need to scale up
- your ingestion cluster.
|