For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs.
Skip to content

PostgreSQL

Minimum PostgreSQL grants for each Nilus pipeline mode: batch read and write, CDC via logical replication, and metadata ingestion.

This page is a provisioning reference for platform and database administrators. It lists the minimum PostgreSQL grants required to run each Nilus pipeline mode against a PostgreSQL depot.

Pipeline modes supported

Pipeline type
URI prefix
Description

type: batch

postgresql://

Full or incremental reads and writes

type: cdc

debezium+postgresql://

Log-based change capture via WAL using pgoutput

type: metadata

metadata+postgresql://

Metadata ingestion

Read data: PostgreSQL as source (type: batch)

Nilus uses this pattern when the depot is referenced in source.address of a pipeline configuration. It issues SELECT queries, either a full scan or an incremental read using a cursor column, against the target table.

Minimum grants

-- Database access
GRANT CONNECT ON DATABASE <database_name> TO <user>;

-- Schema access
GRANT USAGE ON SCHEMA <schema_name> TO <user>;

-- Table read: existing tables
GRANT SELECT ON ALL TABLES IN SCHEMA <schema_name> TO <user>;

-- Table read: future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name>
    GRANT SELECT ON TABLES TO <user>;

These grants cover every table in the schema. To restrict access to a single table, replace ALL TABLES IN SCHEMA with TABLE <table_name>.

CDC source: PostgreSQL (type: cdc)

Server-side prerequisite (one-time, requires superuser or admin)

Nilus requires logical replication to be enabled on the PostgreSQL server before it can capture changes through Debezium. Enabling logical replication is a server-level configuration change: it requires a full restart of the PostgreSQL server and cannot be applied at the session level.

Minimum grants

If a superuser or DBA pre-creates the publication instead of letting Nilus create it, the connector still needs to alter or manage the publication during CDC operation. Grant this by assigning ownership of the publication to the CDC user, or by granting CREATE on the database.

To pre-create the publication instead of granting CREATE ON DATABASE, run:

Write data: PostgreSQL as destination (type: batch, type: cdc)

Nilus uses this pattern when the depot is referenced in sink.address of a pipeline configuration. It manages table creation and data loading.

Minimum grants (covers all strategies)

Grants by incremental strategy

Strategy
Required privileges

append

CONNECT, USAGE, INSERT, CREATE (if new table)

merge

CONNECT, USAGE, INSERT, UPDATE, DELETE, SELECT, CREATE (if new table)

replace

CONNECT, USAGE, INSERT, TRUNCATE, CREATE (if new table)

Metadata ingestion: PostgreSQL source connector (type: metadata)

Nilus uses this pattern when the depot is referenced in source.address of a type: metadata pipeline. Nilus drives the PostgreSQL source connector.

Basic metadata (tables, schemas, columns, views)

Usage and lineage: the pg_stat_statements extension

Nilus metadata pipeline reads query history from the pg_stat_statements extension to build lineage and usage statistics. This requires a one-time admin setup and an additional user grant.

Step 1. Enable the extension (admin, requires server restart).

Step 2. Create the extension and grant access (run as superuser after restart).

pg_stat_statements is an in-memory statistics collector, not a persistent query log:

  • Queries are deduplicated by shape (literal values are replaced with $1, $2, and so on).

  • No timestamps are stored, only cumulative call counts since the last reset.

  • Entries are silently evicted when the hash table is full.

For the best coverage, set pg_stat_statements.max to 10000 or higher, and schedule frequent metadata ingestion runs (every 1-2 hours) to capture queries before eviction.

Stored procedure lineage (additional postgresql.conf change)

To capture SQL executed inside stored procedures:

No additional SQL grants are needed beyond pg_read_all_stats.

Additional grants by workflow type

Workflow
Requirement
What it needs

Basic metadata

SQL grants above

CONNECT, USAGE, SELECT

Usage & lineage

pg_stat_statements enabled + GRANT pg_read_all_stats

pg_stat_statements view

Stored procedure lineage

log_statement = 'all' + pg_stat_statements.track = 'all' in postgresql.conf

Internal query tracking

Permission matrix

Use case

CONNECT DB

USAGE schema

SELECT

INSERT/UPDATE/DELETE

CREATE schema

REPLICATION attr

pg_read_all_stats

Read (source, batch)

Yes

Yes

Yes

No

No

No

No

CDC source

Yes

Yes

Yes (snapshot)

No

Yes (if auto-pub)

Yes

No

Write: append

Yes

Yes

No

INSERT

Yes (if new)

No

No

Write: merge

Yes

Yes

Yes

Yes

Yes (if new)

No

No

Write: replace

Yes

Yes

No

INSERT + TRUNCATE

Yes (if new)

No

No

metadata (basic)

Yes

Yes

Yes

No

No

No

No

usage / lineage

Yes

Yes

Yes

No

No

No

Yes

Notes

  • REPLICATION attribute: This is a server-level user attribute set at user creation time (CREATE USER ... WITH REPLICATION). It cannot be granted with a regular GRANT statement. A superuser or a user with CREATEROLE rights must create or alter the CDC user.

  • wal_level = logical requires a server restart: This is a server configuration change and cannot be applied at the session level. Coordinate with the database administrator before enabling CDC on a production instance.

  • Publication ownership: Nilus uses pgoutput and manages the publication lifecycle. If the publication is pre-created, assign ownership to the CDC user, or grant the CDC user CREATE on the database so the connector can alter the publication.

  • ALTER DEFAULT PRIVILEGES: This applies only to objects created by the grantor. If multiple users create tables in the schema, repeat the statement for each table owner to keep access consistent.

  • pg_stat_statements is not a query log: It evicts entries silently and stores no timestamps. Frequent ingestion scheduling is the primary mitigation.

Last updated

Was this helpful?