Each night 1.5 TB of CSV files land on two ETL hosts and must reach a Greenplum fact table partitioned by day (48 segments). Today a Python job streams them with COPY ... FROM STDIN: it takes six hours, the coordinator's network link sits at 100%, and one malformed row aborts a whole file, so the job restarts from scratch. Another team also needs to load Parquet files from S3 into the same warehouse. Design the loading path: how the data gets into the segments, how bad rows are handled without losing the night, how a reloaded day replaces the old one safely, and what must run after the load so the next morning's reports plan well.
Serve files with gpfdist on the ETL hosts and read them via an external table: every segment pulls in parallel, past the coordinator; S3 via PXF. LOG ERRORS SEGMENT REJECT LIMIT sets bad rows aside. Load a staging table, swap it in as the day's partition, then ANALYZE.
- Loading bulk data with COPY through the coordinator, which turns one process and one network link into the bottleneck
- Letting a single bad row abort a whole file instead of isolating rejected rows in an error log with a limit
- Deleting and re-inserting a day in the live table instead of loading a staging table and swapping the partition
- What does a
SEGMENT REJECT LIMITin percent protect you from that a row count does not? - How does the number of gpfdist processes and files limit how many segments read in parallel?
Why COPY does not scale (Greenplum and its forks Arenadata DB and Greengage DB). COPY ... FROM STDIN is a non-parallel load: every row passes through one process on the coordinator, which parses it and dispatches it to a segment. However many segments there are, the speed is bounded by that process and the coordinator's network link.
The loading path:
- gpfdist on the ETL hosts. Each host runs one or more
gpfdistprocesses serving the file directory. An external table lists them inLOCATION; on read, every segment connects to gpfdist directly, and data flows to the segments in parallel, bypassing the coordinator. Throughput grows with the number of gpfdist processes, files and segments. - Bad rows.
LOG ERRORS SEGMENT REJECT LIMITturns on single-row error isolation: a row that does not parse goes to the error log and the load continues. The limit (rows or a percentage) aborts the load only when bad rows exceed what is reasonable — a sign of a broken file, not a typo. - Replacing a day. The external table is read into a staging table with the same structure, distribution key and storage as the partition. Then checks (row counts, totals) and a swap of the day's partition with that table: readers see either the old day or the new one, with no
DELETEand no bloat. - After the load —
ANALYZEthe new partition, so its rows enter the root statistics GPORCA plans from. Do not count on automatic statistics: by default they fire only for a table with none, and only for its owner. - S3 — through PXF: an external table on
pxf://...?PROFILE=s3:parquet, and every segment reads its share of fragments in parallel.
CREATE READABLE EXTERNAL TABLE ext_clicks (LIKE fact_clicks)
LOCATION ('gpfdist://etl1:8081/clicks/2026-11-08/*.csv',
'gpfdist://etl2:8081/clicks/2026-11-08/*.csv')
FORMAT 'CSV' (HEADER)
LOG ERRORS SEGMENT REJECT LIMIT 1 PERCENT;
CREATE TABLE stage_clicks_20261108 (LIKE fact_clicks)
WITH (appendoptimized = true, orientation = column, compresstype = zstd)
DISTRIBUTED BY (click_id);
INSERT INTO stage_clicks_20261108 SELECT * FROM ext_clicks;
SELECT count(*) FROM gp_read_error_log('ext_clicks'); -- how many rows were rejected, and why
ALTER TABLE fact_clicks EXCHANGE PARTITION FOR (date '2026-11-08')
WITH TABLE stage_clicks_20261108;
ANALYZE fact_clicks_1_prt_p20261108; -- take the partition name from the catalogThe partition-swap syntax differs between releases and forks (EXCHANGE PARTITION in some, ATTACH/DETACH PARTITION in others); the idea is the same — prepare the day separately and put it in with one operation. Re-running the night is safe: the staging table is recreated, and the swap is idempotent per day.