PostgreSQL to StarRocks Data Replication
NineData Data Replication supports schema replication, full replication, and incremental replication from PostgreSQL to StarRocks.
Overview
Use StarRocks for reporting, data warehouse, and ad hoc query workloads. This guide shows how to move PostgreSQL data into StarRocks, initialize the target, keep incremental changes in sync, and verify the result before downstream systems use it.
NineData data replication supports schema, full data, and incremental data replication between data sources. For supported data sources, it also supports bidirectional replication for geo-distributed active-active architectures.
- Schema replication: Replicates object structures between homogeneous and heterogeneous data sources.
- Full data replication: Uses data sharding and row-level concurrent batch replication to improve throughput. Breakpoint resume helps preserve data accuracy, including for tables without primary keys.
- Incremental data replication: Replicates DML and DDL changes for supported object types. Row-level concurrency and hotspot merge processing help maintain replication throughput.
- Bidirectional real-time data replication (only between MySQL instances): Replicates changes in both directions between nodes so data can stay current across participating nodes.
Use these capabilities for full or incremental data replication, migration, synchronization, data integration, and low-downtime migration workflows.
Before you begin
Add the source and target data sources to NineData. For instructions, see Add Data Source.
The source database type is PostgreSQL.
The target database is StarRocks 3.1, 3.0, 2.5, 2.4, 2.3, 2.2, 2.1, or 2.0.
For incremental replication, open
postgresql.confand configure the following parameters. If you do not know the file location, runSHOW config_file;in the psql client.- Set
wal_leveltological. - Set
wal_sender_timeoutto0. This parameter stops replication connections that stay inactive longer than the configured number of milliseconds. The default value is60000. Setting it to0disables the timeout. - Set
max_replication_slotsto a value greater than1. - Set
max_wal_sendersto a value greater than1.
- Set
Make sure the source and target accounts have the following permissions.
Replication Type Source Data Source Target Data Source Full Replication CONNECT, SELECT TABLE-related permissions (ALTER, DROP, SELECT, INSERT, UPDATE, DELETE) Incremental Replication SUPERUSER TABLE-related permissions (ALTER, DROP, SELECT, INSERT, UPDATE, DELETE)
Restrictions
- Check the performance of the source and target data sources before you start the task. Run full replication during off-peak hours when possible because the initial load consumes read and write resources.
- Make sure each replicated table has a primary key or unique constraint, and that column names are unique. Otherwise, duplicate rows may be replicated.
Procedure
Sign in to the NineData Console.
Go to Replication.
On the Replication page, click Create Replication.
On the Source & Target tab, configure the fields in the table, and then click Next.
Parameter Description Name Enter a meaningful task name. Up to 64 characters are supported. Source Select the PostgreSQL data source that contains the objects to replicate. Target Select the StarRocks data source that receives the replicated objects. Type Choose what to replicate to StarRocks. - Schema: Replicate only source database and table schemas. Data is not replicated.
- Full: Replicate all selected source objects and data. This is full data replication.
- Incremental: After full replication completes, replicate incremental changes from source logs.
If target table already exists(Required when Schema is selected) - Pre-Check Error and Stop Task: Stop the task if precheck finds a table with the same name.
- Skip and Continue Task: Continue the task after a prompt. During structure replication, skip the same-name table. If data replication is also enabled, append data to the existing table without overwriting existing data.
- Delete Objects and Rewrite: Continue the task after a prompt. During structure replication, delete the same-name table in the target database and replicate the table structure from the source again. If data replication is also enabled, write data after structure replication completes.
- Keep Schema and Clear Data, then Rewrite(Optional when both structure and data replication are selected): Continue the task after a prompt. During structure replication, keep the target table structure. When data replication starts, clear the data in the same-name table and then replicate data from the source table again.
Target Table Exists Data(Required when Schema is not selected) - Pre-Check Error and Stop Task: Stop the task if precheck finds existing data in the target table.
- Ignore existing target data and append to it.: Ignore existing data in the target table and append other data.
- Clear target existing data before write: Delete existing data in the target table before writing new data.
On the Objects tab, configure the following field, and then click Next.
Parameter Description Replication Objects Select the objects to replicate. Select All Objects to replicate all objects in the source database, or select Customized Object, choose objects in the Source Object list, and click > to move them to the Target Object list. On the Mapping tab, choose the action that matches the selected replication type.
If Schema is included: Configure the target database and table names after structure replication, and then click Save and Pre-Check.
tipClick Mapping & Filtering to customize target column names after replication. Set Data Filter so that only rows that match the filter are replicated. For example, if the filter condition is
emp_no>=10005, rows whoseemp_novalue is less than10005are not replicated.If "Schema" is not included: NineData selects the database with the same name in the target data source by default. If no same-name database exists, select the target database manually. The table and column names in the target database must match the replication objects. If they do not match, map them manually.
On the Pre-check tab, wait for NineData to finish the precheck. After the precheck passes, click Launch.
tip- To compare target data with source data after synchronization, enable Enable data consistency comparison. Depending on the selected Type, Enable data consistency comparison starts as follows:
- Schema: Starts after structure replication completes.
- Schema+Full, Full: Starts after full replication completes.
- Schema+Full+Incremental, Incremental: Starts when incremental data matches the source for the first time and Delay is
0seconds. Click View Details to view the synchronization delay on the Details page.
- If the precheck fails, click Details in the Actions column for the failed item, fix the issue, and then click Check Again to run the precheck again.
- If Result is Warning, fix the issue or ignore the warning.
- To compare target data with source data after synchronization, enable Enable data consistency comparison. Depending on the selected Type, Enable data consistency comparison starts as follows:
On the Launch page, the Launch Successfully message appears and the synchronization task starts. Use these actions:
- Click View Details to view each synchronization stage.
- Click Back to list to return to the Replication task list.
Result
Sign in to the NineData Console.
Go to Replication.
On the Replication page, click the Task ID of the target synchronization task. The task details page contains the following areas.

No. Function Description 1 Synchronization Delay Shows the synchronization delay between the source and target data sources. 0seconds means the target has caught up with the source, which is the expected state before a planned traffic switch.2 Configure Alerts Notifies the selected contacts when the task fails. For more information, see Introduction to Operations Monitoring. 3 More - Pause: Pause a task whose status is Running.
- Terminate: End an unfinished task or a task that is running incremental synchronization. After a task is terminated, it cannot be restarted. Proceed with caution. If the synchronization objects contain triggers, a trigger replication option appears.
- Delete: Delete the task. Deleted tasks cannot be restored. Proceed with caution.
4 Structure Replication (Displayed when structure replication is included) Shows structure replication progress and details. - Click Logs to view structure replication logs.
- Click the
icon to refresh the information.
- Click View DDL in the Operation column of a target object to view SQL replay.
5 Full Replication (Displayed when full replication is included) Shows full replication progress and details. - Click Monitoring to view full replication metrics. On the monitoring page, click Throttle Settings to limit the write rate to the target data source.
- Click Logs to view full replication logs.
- Click the
icon to refresh the information.
6 Incremental Replication (Displayed when incremental replication is included) Shows incremental replication metrics. - Click View Threads to view operations currently running in the replication task, including:
- Thread ID: The current thread ID. A replication task can use multiple threads.
- Execute SQL: Details of the SQL statement that the current thread is executing.
- Response Time: The response time of the current thread. If this value increases, the thread may be blocked.
- Event Time: The timestamp when the current thread started.
- Status: The current thread status.
- Click Throttle Settings to limit the write rate to the target data source. The unit is rows per second.
- Click Logs to view incremental replication logs.
- Click the
icon to refresh the information.
7 Modify Object Shows modification records for synchronization objects. - Click Modify Synchronization Object to update the synchronization scope.
- Click the
icon to refresh the information.
8 Data Comparison Shows data comparison results between the source and target data sources. If data comparison is not enabled, click Enable Data Comparison. - Click Re-compare to compare the current source and target data again.
- Click Logs to view consistency comparison logs.
- Click Monitoring (displayed only for data comparison) to view the comparison RPS trend chart. Click Details to view earlier records.
- Click
in the Operation column of a comparison row to view source and target comparison details.
- Click
in the Operation column when inconsistent data exists to generate change SQL. Copy the SQL to the target data source to fix inconsistent data.
9 Expand Shows current replication task details, including Replication Type, Replication Object, and Start Time.
Appendix 1: Observed PostgreSQL 15.2 to StarRocks 5.1.0 column mappings
The table records column mappings observed in NineData Test from PostgreSQL 15.2 to StarRocks 5.1.0. Source types are the data_type / udt_name values returned by PostgreSQL information_schema.columns; target types and the lengths, precision, and scale in parentheses come from StarRocks information_schema.columns after replication. The mappings apply only to the listed definitions and versions. They do not establish conversion or fidelity of non-NULL values.
| Category | PostgreSQL source type (source column) | StarRocks target column_type | Target catalog metadata |
|---|---|---|---|
| Numeric | boolean (bool_c, bool_alias) | tinyint(1) | numeric_precision not reported; numeric_scale=0 |
| Numeric | smallint (int2_c, int2_alias, smallserial_c) | smallint(6) | Precision 5, scale 0 |
| Numeric | integer (int_c, int_alias, int4_alias, serial_c) | int(11) | Precision 10, scale 0 |
| Numeric | bigint (int8_c, int8_alias, bigserial_c) | bigint(20) | Precision 19, scale 0 |
| Numeric | numeric(20,6) (num_c, decimal_alias) | decimal(20, 6) | Precision 20, scale 6 |
| Numeric | real (real_c, float4_alias) | double | Precision 15, scale 15 (recorded as returned by the target catalog) |
| Numeric | double precision (double_c, float_alias, float8_alias) | double | Precision 15, scale 15 (recorded as returned by the target catalog) |
| Numeric | money (money_c) | decimal(19, 2) | Precision 19, scale 2 |
| Character and binary | bit(8) (bit_c) | varchar(255) | Maximum character length 255 |
| Character and binary | bit varying(16) (varbit_c, varbit_alias) | varchar(255) | Maximum character length 255 |
| Character and binary | character(8) (char_c, char_alias) | char(32) | Maximum character length 32 |
| Character and binary | character varying(32) (varchar_c, varchar_alias) | varchar(128) | Maximum character length 128 |
| Character and binary | text (text_c) | varchar(65533) | Maximum character length 65533 |
| Character and binary | PostgreSQL internal type "char" (char_internal) | varchar(255) | Maximum character length 255 |
| Character and binary | bytea (bytea_c) | varchar(65533) | Maximum character length 65533 |
| Date and time | date (date_c) | date | Length, precision, and scale not reported by the target catalog |
| Date and time | time(6) without time zone (time_c) | varchar(255) | Maximum character length 255 |
| Date and time | time(6) with time zone (timetz_c, timetz_alias) | varchar(255) | Maximum character length 255 |
| Date and time | timestamp(6) without time zone (timestamp_c) | datetime | Length, precision, and scale not reported by the target catalog |
| Date and time | timestamp(6) with time zone (timestamptz_c, timestamptz_alias) | datetime | Length, precision, and scale not reported by the target catalog |
| Date and time | interval(3) (interval_c) | varchar(255) | Maximum character length 255 |
| Geometric | point, line, lseg, box, path, polygon, circle (corresponding _c source columns) | varchar(255) for each column | Maximum character length 255 for each column |
| Network address | cidr, inet, macaddr, macaddr8 (corresponding _c source columns) | varchar(255) for each column | Maximum character length 255 for each column |
| Text search | tsvector (tsvector_c), tsquery (tsquery_c) | varchar(255) for each column | Maximum character length 255 for each column |
| Identifiers and documents | uuid (uuid_c) | varchar(36) | Maximum character length 36 |
| Identifiers and documents | xml (xml_c), json (json_c) | varchar(65533) for each column | Maximum character length 65533 for each column |
| JSON, range, and system types | jsonb, jsonpath, int4range, int8range, numrange, tsrange, tstzrange, daterange, int4multirange, int8multirange, nummultirange, tsmultirange, tstzmultirange, datemultirange (corresponding _c source columns) | varchar(255) for each column | Maximum character length 255 for each column |
| Object identifier and system types | oid, regclass, regcollation, regconfig, regdictionary, regnamespace, regoper, regoperator, regproc, regprocedure, regrole, regtype, xid, xid8, cid, tid, pg_lsn, pg_snapshot, txid_snapshot (corresponding _c source columns) | varchar(255) for each column | Maximum character length 255 for each column |
| Arrays | bool_arr (udt_name=_bool), int2_arr (_int2), int4_arr (_int4), int8_arr (_int8), numeric_arr (_numeric), real_arr (_float4), double_arr (_float8), money_arr (_money), bit_arr (_bit), varbit_arr (_varbit), char_arr (_bpchar), varchar_arr (_varchar), text_arr (_text), bytea_arr (_bytea), date_arr (_date), time_arr (_time), timetz_arr (_timetz), timestamp_arr (_timestamp), timestamptz_arr (_timestamptz), interval_arr (_interval), point_arr (_point), line_arr (_line), lseg_arr (_lseg), box_arr (_box), path_arr (_path), polygon_arr (_polygon), circle_arr (_circle), cidr_arr (_cidr), inet_arr (_inet), macaddr_arr (_macaddr), macaddr8_arr (_macaddr8), tsvector_arr (_tsvector), tsquery_arr (_tsquery), uuid_arr (_uuid), xml_arr (_xml), json_arr (_json), jsonb_arr (_jsonb), jsonpath_arr (_jsonpath), int4range_arr (_int4range), int8range_arr (_int8range), numrange_arr (_numrange), tsrange_arr (_tsrange), tstzrange_arr (_tstzrange), daterange_arr (_daterange), int4multi_arr (_int4multirange), int8multi_arr (_int8multirange), nummulti_arr (_nummultirange), tsmulti_arr (_tsmultirange), tstzmulti_arr (_tstzmultirange), datemulti_arr (_datemultirange), oid_arr (_oid), regclass_arr (_regclass), regcollation_arr (_regcollation), regconfig_arr (_regconfig), regdict_arr (_regdictionary), regnamespace_arr (_regnamespace), regoper_arr (_regoper), regoperator_arr (_regoperator), regproc_arr (_regproc), regprocedure_arr (_regprocedure), regrole_arr (_regrole), regtype_arr (_regtype), xid_arr (_xid), xid8_arr (_xid8), cid_arr (_cid), tid_arr (_tid), pg_lsn_arr (_pg_lsn), pg_snapshot_arr (_pg_snapshot), txid_snapshot_arr (_txid_snapshot) | Every array column is varchar(65533) | Maximum character length 65533 for each column |
The main fixture contained 156 type columns (87 non-array and 69 array columns) plus one helper column. Structure replication completed for all columns in task rp-dmqf8rlwm7y1, and the target catalog returned 157 columns. The full-copy stage is marked completed, but its completed-record count is 0. Therefore, this table describes column definitions only, not non-NULL value conversion. PostgreSQL's information schema normalizes some aliases to their underlying types; this table records the returned data_type / udt_name values and does not infer the original spelling from column names.
Separate tasks provided these additional column observations: PostgreSQL name → varchar(255); name[] (udt_name=_name) and internal type "char"[] (udt_name=_char) → varchar(65533); user-defined enum / composite examples → varchar(255) and a domain example → decimal(10,2). These results apply only to the specific test columns and do not represent all user-defined types. PostgreSQL pseudo-types are not ordinary table-column mappings.
See the PostgreSQL 15 data type documentation and its sections on arrays, ranges, and object identifier types for the source type scope. This table reports only the tested columns and version combination; do not extrapolate it to other versions or unlisted types.