Skip to content

pg_lamina

Transactional PostgreSQL-hosted Parquet analytics with DataFusion

pg_lamina · Transactional PostgreSQL-hosted Parquet analytics with DataFusion

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
102320pg_laminapg_lamina0.3.1OLAPMITRust

PostgreSQL · 17, 18, 19

Usage

Sources:

pg_lamina 0.3.0 stores transactional Parquet segments in PostgreSQL tables and runs analytical queries through DataFusion. It supports PostgreSQL17–19. Conversion now preserves the original heap and attaches insert ingestion; it does not reproduce UPDATE or DELETE in the analytical copy.

Convert and Query

A superuser installs the extension and uses the current lamina schema:

CREATE EXTENSION pg_lamina;
CREATE TABLE public.lamina_source (region text, amount double precision);
INSERT INTO public.lamina_source VALUES ('west', 125), ('west', 200);
BEGIN;
SELECT lamina.convert_table('public.lamina_source', 'events');
SELECT * FROM lamina.query(
  'SELECT region, sum(amount) AS total FROM events GROUP BY region'
);
COMMIT;

Conversion takes an exclusive lock until transaction end and accepts ordinary logged heap tables. It retains the source on commit; rollback discards the conversion. Analytical tables are catalog entries, not normal PostgreSQL relations. Source indexes, constraints, defaults and permissions are not transferred.

Ingestion and Maintenance

INSERT INTO public.lamina_source VALUES ('east', 80);
SELECT lamina.flush_table('events');
SELECT lamina.compact_table('events');
SELECT name, row_count FROM lamina.tables;
SELECT lamina.profile_query('SELECT count(*) FROM events');

The statement trigger buffers INSERT/COPY rows in logged delta tables, immediately visible to lamina.query. lamina.ingest_batch_rows controls flushing: 0 flushes each statement and -1 waits for explicit flushing. lamina.append_table accepts matching batch tables and an explicit drop/truncate/keep cleanup policy. lamina.attach_staging_table and lamina.detach_staging_table manage ingestion triggers. Compaction rewrites segments and summaries.

Boundaries and Upgrade

lamina.query uses DataFusion semantics, is read-only, requires a superuser and returns at most 10,000 rows. Supported types include booleans, integer types, double precision, text and finite dates/timestamps without time zone. Numeric, timestamptz, arrays and domains are unsupported. Partitioned, inherited, temporary and unlogged sources are unsupported.

lamina.memory_limit_mb bounds tracked query memory; lamina.query_workers and per-backend caches need separate sizing. This release stores segments and delta rows in WAL-logged tables covered by PostgreSQL backups and physical replication. Restore targets need matching extension binaries. Install the new library/SQL, follow the upstream restart procedure and run:

ALTER EXTENSION pg_lamina UPDATE TO '0.3.0';

The upgrade preserves existing segments. Legacy pg_analytics/analytics prerelease images are a separate compatibility boundary and must not be treated as interchangeable with versioned pg_lamina installations.

Version 0.3.1

Release 0.3.1 retains the PostgreSQL 17–19 interface and storage boundaries above. The supplied 0.3.0-to-0.3.1 script is a version transition with no SQL object changes. After installing matching binaries and upgrade files and following the upstream restart procedure, use ALTER EXTENSION pg_lamina UPDATE TO '0.3.1'. Earlier installations must have the complete supported upgrade chain available; the older README example stops at 0.3.0.

Table reader