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

Configuration reference for the PostgreSQL metadata source: supported stages, source options, required grants, and troubleshooting.

PostgreSQL is supported as a metadata source. A spec.type: metadata pipeline introspects a PostgreSQL database and publishes source context: databases, schemas, tables, views, columns, profiles, lineage, usage, and classification. It does not copy table rows.

For batch row movement out of PostgreSQL, see the PostgreSQL (batch); for change data capture, see the PostgreSQL (CDC). For the field-by-field authoring contract, see Metadata pipeline config.

Metadata stages

service_type: postgres supports the full DAG. The required mode field decides how much of it runs: shallow runs metadata + lineage; deep adds profiler, classification, and usage. Source inventory (metadata) runs first; once it succeeds, the remaining stages run in parallel.

Stage
Runs in
What it lands in the catalog

metadata

shallow, deep

Databases, schemas, tables, views, partitioned tables, foreign tables, columns (with data types, nullability, defaults), primary/foreign-key constraints, and object descriptions (comments).

lineage

shallow, deep

Asset and column lineage parsed from view definitions and, when query statistics are available, from the query log.

profiler

deep

Per-column statistics (row counts, null counts, distinct counts, min/max, basic distributions) and table-level metrics.

classification

deep

Auto-classification tags applied to columns from sampled data (PII heuristics).

usage

deep

Query popularity and access frequency derived from query statistics.

The first successful run establishes the source inventory and lineage. In deep, profiles, classification, and usage then deepen it. A frequent shallow pipeline keeps inventory and lineage fresh; pair it with a less frequent deep pipeline for the full profile.

Asset hierarchy

PostgreSQL assets map into the Datasets App as Database → Schema → Table/View → Column. Partitioned tables surface as a single logical table; foreign tables (postgres_fdw and similar) surface as tables with their remote definition captured.

Source options

Metadata pipelines accept only the customer-facing source.options keys below. Do not set source_table. Nilus assigns a stage-specific value to each DAG node internally.

Option
Required
Used by stages
Description

service_type

Yes

all

Must be postgres (alias postgresql).

database_filter

No

see below

Optional include/exclude regexes. Ignored for inventory: PostgreSQL always binds one database. On classification / profiler, resolved against databases already in the catalog.

schema_filter

No

all

Restrict by schema name. Same shape as database_filter.

table_filter

No

all

Restrict by table / view name. Same shape as database_filter.

query_log_duration

No

lineage, usage

Days of query statistics to ingest per run. Defaults to 1. Used by lineage (both modes) and usage (deep only).

result_limit

No

lineage, usage

Maximum number of query rows to fetch per run. Defaults to 10000000. Used by lineage (both modes) and usage (deep only).

threads

No

profiler, usage

Parallel worker count for the heavier stages. Raise it to cut runtime on large scopes.

mode (shallow or deep) is a required spec field, not a source.options key. See Metadata pipeline config: choosing a mode.

Required permissions

A metadata pipeline needs read access to the catalog and, for the enrichment stages, to the data and query statistics:

  • CONNECT on the target database and USAGE on the schemas in scope;

  • SELECT on the tables and views in scope. This is required for metadata (constraint reflection), profiler, and classification (which sample rows).

  • for lineage and usage, access to query statistics through the pg_stat_statements extension. Grant the login the pg_read_all_stats (or pg_monitor) role so it can read the statement statistics view.

Example grant pattern for a dedicated metadata login:

Inventory and profiling work without pg_stat_statements; only lineage and usage depend on it. On managed PostgreSQL (RDS, Cloud SQL, Azure Database) enable pg_stat_statements through the parameter group / server flags before expecting lineage or usage output.

Sample Nilus config

Project credentials through spec.use.projection:

With mode: deep, the depot-backed resource above produces a five-node DAG (metadata root → lineage, profiler, classification, usage). Switch to mode: shallow for a 2-node metadata + lineage DAG. For more ready-to-edit examples, see Metadata sample configs.

Behavior and capabilities

  • Connection: Use a PostgreSQL depot (dataos://<depot>?purpose=rw) or a direct postgresql://... URI with projected credentials. Because spec.type is metadata, Nilus adds the internal metadata+ routing prefix automatically. A depot bundles host, port, database, and TLS material with the credentials in one place. Add ?sslmode=require (or verify-ca / verify-full) to the direct URI for TLS; sslmode defaults to disable when omitted. Both the depot and URI require a database. Omitting it from a URI fails validation before a connection is attempted. PostgreSQL has no account-level scan.

  • database_filter does not change inventory: The metadata stage always scans the bound database. Extra includes names do not add databases to inventory. On classification / profiler, a multi-entry filter is honoured for every named database already in the catalog, including one this connection is not bound to. A name that is not catalogued is a no-op. With no filter, classification stays in the bound database rather than roaming the catalog. See How database_filter is evaluated.

  • Identifier case: PostgreSQL folds unquoted identifiers to lower-case. Use lower-case forms in filter patterns to match how objects are reported.

  • Scope discipline: Bound inventory with schema_filter / table_filter. Exclude pg_catalog, information_schema, and temporary/audit schemas.

  • Query statistics: Lineage and usage read from pg_stat_statements. Without the extension, inventory and profiling still succeed but lineage/usage output will be empty.

Troubleshooting

Symptom
Likely cause
Resolution

FATAL: password authentication failed

Wrong username/password, or the login lacks CONNECT.

Verify the projected secret and GRANT CONNECT ON DATABASE.

SSL connection required / TLS errors

Server enforces TLS but the URI omits sslmode.

Add ?sslmode=require (or verify-ca / verify-full) to the URI.

Inventory lands but lineage/usage are empty

pg_stat_statements is not enabled, or the login can't read it.

Enable the extension and grant pg_read_all_stats (or pg_monitor).

Profiler/classification skip tables

The login has catalog visibility but no SELECT on the data.

Grant SELECT on the tables in scope (and set default privileges for new tables).

A stage runs for hours

The extraction scope is unbounded.

Tighten schema_filter / table_filter; raise threads. database_filter does not shrink inventory.

Extra databases in includes never appear in inventory

PostgreSQL always binds one database.

Inventory is the URI/depot database. Extra names only affect classification/profiler if those databases are already in the catalog.

Last updated

Was this helpful?