Monitor Order Fulfillment with PostgreSQL and VeloDB Cloud
A paid order can still sit unshipped for hours. Operations teams need a simple way to find these orders before they become customer complaints.
In this tutorial, PostgreSQL continues to process order updates while VeloDB Cloud maintains an analytical copy of the relevant tables. A single query finds paid orders that have not shipped within one hour and adds the merchant information needed to investigate them.
Order updates in PostgreSQL
↓
Full and incremental sync into VeloDB Cloud
↓
Join orders with merchant information
↓
Find paid orders that are more than one hour late
All names, IDs, regions, timestamps, and amounts in this tutorial are synthetic.
Prerequisites
This tutorial uses managed PostgreSQL import, which is in Public Preview and currently documented for VeloDB Cloud 26.1.x warehouses. Check that guide for source configuration and version requirements before creating a job.
You need:
- A reachable PostgreSQL 14 or later source.
- A running VeloDB Cloud warehouse with permission to create the target database, tables, and import job. Follow the VeloDB Cloud Quick Start if you need to create one.
- A PostgreSQL user that can read the selected tables and stream their changes.
- Logical write-ahead logging enabled on the PostgreSQL source.
Use a dedicated demo database on a supported PostgreSQL deployment. For Amazon RDS or Aurora, complete the provider-specific setup linked from the PostgreSQL import guide.
Follow Connect for Import to prepare connectivity for your SaaS or BYOC warehouse. For this walkthrough, use a publicly reachable demo source with restricted network access. A private source needs the network configuration described in that guide.
1. Create the sample order data
Connect to a dedicated PostgreSQL demo database and use its public schema. The script creates tables if they do not exist, but it does not update an existing schema. Avoid using tables that contain other data.
Run the following PostgreSQL SQL. Orders 10001 and 10003 are overdue, while order 10002 has already shipped.
SET TIME ZONE 'UTC';
SET search_path TO public;
CREATE TABLE IF NOT EXISTS merchants (
merchant_id BIGINT PRIMARY KEY,
merchant_name VARCHAR(100) NOT NULL,
region VARCHAR(50) NOT NULL
);
CREATE TABLE IF NOT EXISTS orders (
order_id BIGINT PRIMARY KEY,
merchant_id BIGINT NOT NULL,
customer_id BIGINT NOT NULL,
status VARCHAR(20) NOT NULL,
paid_at TIMESTAMP,
shipped_at TIMESTAMP,
amount NUMERIC(10, 2) NOT NULL,
updated_at TIMESTAMP NOT NULL
);
INSERT INTO merchants (merchant_id, merchant_name, region)
VALUES
(101, 'Northstar Home', 'East'),
(102, 'Greenfield Electronics', 'South')
ON CONFLICT (merchant_id) DO UPDATE
SET merchant_name = EXCLUDED.merchant_name,
region = EXCLUDED.region;
INSERT INTO orders (
order_id, merchant_id, customer_id, status,
paid_at, shipped_at, amount, updated_at
)
VALUES
(
10001, 101, 90001, 'paid',
NOW() - INTERVAL '2 hours', NULL, 299.00, NOW()
),
(
10002, 102, 90002, 'shipped',
NOW() - INTERVAL '2 hours',
NOW() - INTERVAL '80 minutes', 499.00, NOW()
),
(
10003, 101, 90003, 'paid',
NOW() - INTERVAL '110 minutes', NULL, 99.00, NOW()
)
ON CONFLICT (order_id) DO UPDATE
SET merchant_id = EXCLUDED.merchant_id,
customer_id = EXCLUDED.customer_id,
status = EXCLUDED.status,
paid_at = EXCLUDED.paid_at,
shipped_at = EXCLUDED.shipped_at,
amount = EXCLUDED.amount,
updated_at = EXCLUDED.updated_at;
The ON CONFLICT clauses make the sample reusable. Running the script again resets the same fictional rows instead of creating duplicates.
Verify the source data:
SELECT
order_id,
status,
paid_at,
shipped_at,
amount
FROM orders
ORDER BY order_id;
2. Confirm logical replication support
Incremental synchronization uses PostgreSQL logical write-ahead logging. Check the current setting:
SHOW wal_level;
The expected result is logical. This check alone is not sufficient: the import user also needs replication and table permissions, and the source needs the replication resources required by the PostgreSQL import guide. If a setting must change, follow your provider's instructions before creating the job.
3. Sync PostgreSQL into VeloDB Cloud
- Log in to the VeloDB Cloud console.
- In the upper-left corner, select the warehouse that you want to use.
- In the left navigation pane, click Data Integration.
- Click Add Import Job on the initial page. If integration records already exist, in the upper-right corner, choose Add Data > Import data into VeloDB. Select PostgreSQL, then click Continue. For more information about the wizard, see Import Data.
Configure the source connection:
| Setting | Example value |
|---|---|
| Job Name | postgres_order_demo_to_velodb |
| Host | <your-postgresql-host> |
| Port | <your-postgresql-port> |
| Database | <your-postgresql-database> |
| User | <your-postgresql-user> |
| Password | Enter the password in the console. Do not add it to source code. |
| Enable SSL | Enable encrypted connections to the source. |
Use the actual port shown by your provider instead of assuming the standard PostgreSQL port of 5432.
Then configure the destination and tables:
| Setting | Value used in this tutorial |
|---|---|
| Target Database | Select New Database and enter order_demo_postgres_velodb. |
| Sync Type | Initial Load + Incremental Sync |
| Source schema | public |
| Select Tables to Migrate | public.orders and public.merchants |
| Sync Interval (s) | 60 |
Initial Load + Incremental Sync first copies the existing rows and then continues to capture new inserts and updates. An incremental-only job does not include rows that existed before the job started.
For a SaaS warehouse and this public demo source, leave Reverse Private Endpoint disabled. For a private source, use the network path prepared in Connect for Import. BYOC source connectivity is configured in your cloud network.
The wizard provides Enable SSL for encrypted source connections. If your source requires additional certificate configuration, contact VeloDB Cloud support to confirm the connection options.
Under Settings, select the target Cluster and set Sync Interval (s) to 60. Complete Verify and Confirm, resolve any failed pre-checks, and click Start. Open Import Jobs to monitor the initial load before running the verification queries.
Do not publish the source hostname, connection URI, username, password, or certificate. The values above are placeholders.
4. Verify the initial sync
When the initial load completes for both tables, confirm in SQL Editor that VeloDB Cloud contains three orders and two merchants:
SELECT COUNT(*) AS order_count
FROM order_demo_postgres_velodb.orders;
SELECT COUNT(*) AS merchant_count
FROM order_demo_postgres_velodb.merchants;
The source statements use PostgreSQL syntax. The following analytical queries use VeloDB Cloud SQL syntax, so the date functions differ.
5. Find overdue orders
Run the following query in SQL Editor. The source setup uses UTC timestamps, so set the query session to UTC for the one-hour comparison.
SET time_zone = 'UTC';
SELECT
o.order_id,
m.merchant_name,
m.region,
o.amount,
o.paid_at,
TIMESTAMPDIFF(MINUTE, o.paid_at, NOW()) AS minutes_waiting
FROM order_demo_postgres_velodb.orders AS o
JOIN order_demo_postgres_velodb.merchants AS m
ON o.merchant_id = m.merchant_id
WHERE o.status = 'paid'
AND o.shipped_at IS NULL
AND o.paid_at < DATE_SUB(NOW(), INTERVAL 1 HOUR)
ORDER BY o.paid_at;
The query combines the latest order status with merchant context and returns only orders that have exceeded the one-hour fulfillment threshold.

Orders 10001 and 10003 both require attention. The exact minutes_waiting values depend on when you run the query.
6. Mark an order as shipped in PostgreSQL
Update order 10001 in the source PostgreSQL database:
UPDATE orders
SET status = 'shipped',
shipped_at = NOW(),
updated_at = NOW()
WHERE order_id = 10001;
This update represents the normal business event that occurs when a fulfillment center ships an order.
Optional: run the update with Python
Set PGHOST, PGPORT, PGDATABASE, PGUSER, and PGPASSWORD for your demo database. Set PGSSLROOTCERT to the local path of the CA certificate provided by your PostgreSQL host. The script reads these environment variables and verifies the server certificate and hostname:
python3 -m pip install "psycopg[binary]"
import os
import psycopg
connection_options = dict(
host=os.environ["PGHOST"],
port=os.environ["PGPORT"],
dbname=os.environ["PGDATABASE"],
user=os.environ["PGUSER"],
password=os.environ["PGPASSWORD"],
sslmode="verify-full",
sslrootcert=os.environ["PGSSLROOTCERT"],
options="-c timezone=UTC",
)
with psycopg.connect(**connection_options) as connection:
with connection.cursor() as cursor:
cursor.execute("""
UPDATE orders
SET status = 'shipped',
shipped_at = NOW(),
updated_at = NOW()
WHERE order_id = 10001
""")
Use a secret manager for credentials in production. Never publish the source hostname, connection URI, username, password, or certificate.
7. Confirm the change in VeloDB Cloud
Wait for a successful synchronization cycle, then run the overdue-order query again. The configured interval is a scheduling setting, so the change can take longer than one interval to become visible.

Verify the source update in VeloDB Cloud:
SELECT order_id, status, shipped_at
FROM order_demo_postgres_velodb.orders
WHERE order_id = 10001;
The row should show shipped and a non-null shipped_at. Order 10001 is no longer returned by the overdue-order query because it is now marked as shipped. The row was not deleted from VeloDB Cloud. It simply no longer matches the exception filter. Order 10003 remains because it is still paid, overdue, and unshipped.
The example uses a 60-second sync interval. Actual freshness depends on source activity, job backlog, and available resources. Verify the changed values before relying on an empty exception result.
Why use VeloDB Cloud for this workflow?
PostgreSQL remains responsible for order transactions. VeloDB Cloud receives a continuously updated analytical copy and runs the operational query, including the join between order and merchant data.
This separation lets teams build fulfillment dashboards and exception reports without placing the same analytical workload on the transactional database. You can extend the pattern to cancellations, payment failures, warehouse delays, inventory shortages, and regional fulfillment trends.
Common errors
| Symptom | What to check |
|---|---|
| The connection pre-check fails | Confirm the source host and port, network access rules, TLS certificates, and the selected private endpoint if used. |
| Existing rows do not appear | Confirm that Initial Load + Incremental Sync is selected and that the initial load completed for every selected table. |
| A source update does not appear | Open the import job details and inspect failed tasks. Check replication permissions, source change-log configuration, and job backlog. |
| Counts or query results differ from the example | Check that you selected the demo source tables and the correct target database. Rerun the setup only in the dedicated demo database to restore the starting state. |
For an overdue-order result that differs from the example, also check that the source setup and the SQL Editor session use UTC. A session time-zone difference can change the one-hour comparison.
Cost and cleanup
The source database, running warehouse compute, stored data, and data transfer can incur charges. Review Billing before leaving the demo running.
When you finish:
-
In Data Integration > Import Jobs, find the demo job, choose Delete, and confirm that you are deleting the demo job.
-
If the target database contains only this tutorial's data, remove it in SQL Editor:
DROP DATABASE order_demo_postgres_velodb; -
Remove the synthetic source tables or source database only after confirming that they are dedicated to this tutorial.
-
If you created a cluster solely for the demo, pause it when it has no other workloads. Pausing compute does not remove retained storage or cache charges.
Production considerations
- Use a dedicated PostgreSQL account with only the permissions required for synchronization.
- Confirm that logical replication and the required permissions are configured for the source deployment.
- Store credentials in a secret manager instead of scripts or screenshots.
- Use TLS certificate verification and private networking when appropriate.
- Choose a synchronization interval that matches the operational requirement, then validate it under the expected workload.
- Monitor synchronization status and lag before using the data for alerts.
- Replace the synthetic sample with approved and properly governed production data.
To build the same workflow from a MySQL source, see Monitor Order Fulfillment with MySQL and VeloDB Cloud.