
An equipment rental company replicates 126 Db2 for IBM i tables into PostgreSQL, about 2 million changes a day, with 2 to 3 seconds of lag and peaks of 5 to 6. To replace the tool doing it, Maia had to do at least as well. We added a PostgreSQL destination to Maia's streaming runner, proved it on a real IBM i, and load-tested it at their scale. Median lag held at 1.3 to 1.4 seconds and the slowest change took 2.6 seconds, even at 18 times their average change rate. The proof-of-concept build took about 2 days.
What they needed
- 126 tables, all streaming at once.
- 21 tables with no unique key, kept as exact copies by keying on the IBM i relative record number (RRN).
- About 2 million changes a day, an average of 56 a second in business hours.
- Lag at or below today's 2 to 3 seconds.
How change data capture (CDC) reads IBM i
With IMAGES(*BOTH), every write to a journaled IBM i table produces a journal entry holding the row before and after the change. Maia's streaming runner reads those entries in order and turns each into a change event, so the tables themselves are queried only once, for the initial load. Deletes arrive like any other change. Restart the pipeline and the runner picks up the journal where it left off, without repeating the initial load.
The IBM i needs each table journaled with IMAGES(*BOTH), a read-only user with USAGE on each schema and SELECT on each table, and *USE authority on the journal and its receivers. The runner writes nothing on the IBM i. The Db2 for IBM i setup guide covers it.
What we built
- A PostgreSQL destination. Each flush applies the last change per key as deletes and upserts, in one transaction per table. The runner moves its place in the journal only after that transaction commits, so no change is skipped.
- RRN keys for tables without a primary key. The initial load now carries each row's RRN, as journal changes already did, and it becomes the table's key in PostgreSQL. Two identical source rows stay two rows.
- A max delay per pipeline. The runner holds each table's changes for at most this long before writing. One second is what makes 1 to 3 seconds of lag possible.
- Column additions and widening. New source columns are added and columns widen when the source type grows. A change a column can't be widened to hold stops the pipeline before anything is written.
The results
The scale test ran 126 tables for 45 minutes in AWS, with 585,991 changes (40% inserts, 50% updates, 10% deletes).
All 105 keyed tables were identical to their source, column for column. In the scale test the 21 tables without a key were appended as a change log, because a PostgreSQL source has no record number; RRN keying was proven on the real IBM i. The initial load copied 1.26 million rows in 30 seconds, and at 1,000 changes a second the runner used about a tenth of one CPU and 670 MiB of memory.
On a real IBM i (PUB400, a shared public IBM i 7.5 system), 60 probe changes arrived in 1.6 seconds at the median and 2.8 seconds at most. The RRN-keyed table stayed identical row for row through duplicate inserts, updates, deletes, and reused record numbers. The scale test used a PostgreSQL source standing in for the IBM i, because the destination applies changes the same way whatever the source.
Where else this applies
Many IBM i files have no primary key. Without one, a change can't be matched to a target row, so the table can only be appended to as a change log; keying on the RRN keeps it as a true copy. Most of the measured lag is the 1-second hold before each write. That's by design: one transaction per table rather than one per change.
What to watch for
- Reorganized files.
RGZPFM, a restore, or a copy renumbers a file's rows, and an RRN-keyed table then needs reloading. - One journal per pipeline. Tables spread across several journals need a pipeline each.
- Per-table transactions. A source transaction that touches several tables can be partly visible for up to the max delay.
- Not supported: multi-member files, and table names that need double quotes in SQL. A truncate on the source stops the pipeline instead of being skipped, which would leave rows the source no longer has.
The PostgreSQL destination, RRN keys on the initial load, and the per-pipeline max delay are a proof of concept, not released Maia features. At AWS list prices, the runner at the size tested (4 vCPU, 8 GB) would cost about $144 a month on Fargate, before Maia platform charges. A smaller size is likely enough but wasn't tested.
Frequently Asked Questions
We've built and demonstrated a PostgreSQL destination for Maia's streaming runner in a proof of concept. It isn't a released Maia feature.
Key it on the relative record number, carried on both initial-load rows and journal changes.
Tables journaled with IMAGES(*BOTH), a user with USAGE on each schema and SELECT on each table, and *USE authority on the journal and receivers.
In testing, 1.3 to 1.4 seconds at the median with a 1-second max delay. The slowest change took 2.6 seconds in the scale test and 2.8 seconds on a shared public IBM i.
Our latest resources
Data management



