Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/bake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- pgvector
- postgis
- pgaudit
- pg_ivm

defaults:
run:
Expand Down Expand Up @@ -52,6 +53,9 @@ jobs:
pgaudit:
- 'pgaudit/**'
- *shared
pg_ivm:
- 'pg_ivm/**'
- *shared

# Compute a matrix containing the list of all extensions that have been modified
- name: Compute matrix
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ they are maintained by their respective authors, and PostgreSQL Debian Group
| Extension | Description | Project URL |
| :--- | :--- | :--- |
| **[pgAudit](pgaudit)** | PostgreSQL audit extension | [https://github.com/pgaudit/pgaudit](https://github.com/pgaudit/pgaudit) |
| **[pg_ivm](pg_ivm)** | Incremental View Maintenance for PostgreSQL | [https://github.com/sraoss/pg_ivm](https://github.com/sraoss/pg_ivm) |
| **[pgvector](pgvector)** | Vector similarity search for PostgreSQL | [https://github.com/pgvector/pgvector](https://github.com/pgvector/pgvector) |
| **[PostGIS](postgis)** | Geospatial database extension for PostgreSQL | [https://postgis.net/](https://postgis.net/) |

Expand Down
35 changes: 35 additions & 0 deletions pg_ivm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ARG BASE=ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
FROM $BASE AS builder

ARG PG_MAJOR
ARG EXT_VERSION

USER 0

RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
git \
postgresql-server-dev-${PG_MAJOR}; \
# Clone and build pg_ivm from source
git clone --branch "v${EXT_VERSION}" --depth 1 https://github.com/sraoss/pg_ivm.git /build/pg_ivm; \
cd /build/pg_ivm; \
make USE_PGXS=1; \
make USE_PGXS=1 install

FROM scratch
ARG PG_MAJOR

# Licenses
COPY --from=builder /build/pg_ivm/LICENSE /licenses/pg_ivm/LICENSE

# Libraries
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/pg_ivm* /lib/
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode/

# Share
COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/pg_ivm* /share/extension/

USER 65532:65532
63 changes: 63 additions & 0 deletions pg_ivm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# pg_ivm Extension

[pg_ivm](https://github.com/sraoss/pg_ivm) is an open-source extension
that provides **Incremental View Maintenance (IVM)** for PostgreSQL, allowing
materialized views to be updated incrementally when base tables change.

## Usage

### 1. Add the pg_ivm extension image to your Cluster

Define the `pg_ivm` extension under the `postgresql.extensions` section of
your `Cluster` resource. For example:

```yaml
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cluster-pg-ivm
spec:
imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
instances: 1

storage:
size: 1Gi

postgresql:
shared_preload_libraries:
- "pg_ivm"
postgresql:
extensions:
- name: pg_ivm
image:
reference: ghcr.io/cloudnative-pg/pg_ivm:1.13-18-trixie
```

### 2. Enable the extension in a database

You can install `pg_ivm` in a specific database by creating or updating a
`Database` resource. For example, to enable it in the `app` database:

```yaml
apiVersion: postgresql.cnpg.io/v1
kind: Database
metadata:
name: cluster-pg-ivm-app
spec:
name: app
owner: app
cluster:
name: cluster-pg-ivm
extensions:
- name: pg_ivm
```

### 3. Verify installation

Once the database is ready, connect to it with `psql` and run:

```sql
\dx
```

You should see `pg_ivm` listed among the installed extensions.
20 changes: 20 additions & 0 deletions pg_ivm/metadata.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
metadata = {
name = "pg_ivm"
sql_name = "pg_ivm"
image_name = "pg_ivm"
shared_preload_libraries = []
extension_control_path = []
dynamic_library_path = []
ld_library_path = []

versions = {
bookworm = {
// pg_ivm version from GitHub releases
"18" = "1.13"
}
trixie = {
// pg_ivm version from GitHub releases
"18" = "1.13"
}
}
}