Skip to content

Commit cdac710

Browse files
shusaanNiccoloFei
authored andcommitted
feat(pg_ivm): add pg_ivm extension container image
- Add pg_ivm Dockerfile with multi-stage build - Create pg_ivm README with usage instructions for CloudNativePG clusters - Add pg_ivm metadata.hcl with version configuration for PostgreSQL 18 - Update main README.md to include pg_ivm in the extensions table Signed-off-by: Husn E Rabbi <shussan@gmail.com>
1 parent fd09e3f commit cdac710

File tree

4 files changed

+116
-0
lines changed

4 files changed

+116
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ they are maintained by their respective authors, and PostgreSQL Debian Group
3636
| :--- | :--- | :--- |
3737
| **[pgAudit](pgaudit)** | PostgreSQL audit extension | [github.com/pgaudit/pgaudit](https://github.com/pgaudit/pgaudit) |
3838
| **[pg_crash](pg-crash)** | **Disruptive** fault injection and chaos engineering extension | [github.com/cybertec-postgresql/pg_crash](https://github.com/cybertec-postgresql/pg_crash) |
39+
| **[pg_ivm](pg_ivm)** | Incremental View Maintenance for PostgreSQL | [github.com/sraoss/pg_ivm](https://github.com/sraoss/pg_ivm) |
3940
| **[pgvector](pgvector)** | Vector similarity search for PostgreSQL | [github.com/pgvector/pgvector](https://github.com/pgvector/pgvector) |
4041
| **[PostGIS](postgis)** | Geospatial database extension for PostgreSQL | [postgis.net/](https://postgis.net/) |
4142

pg_ivm/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ARG BASE=ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
2+
FROM $BASE AS builder
3+
4+
ARG PG_MAJOR
5+
ARG EXT_VERSION
6+
7+
USER 0
8+
9+
RUN set -eux; \
10+
apt-get update; \
11+
apt-get install -y --no-install-recommends \
12+
build-essential \
13+
ca-certificates \
14+
git \
15+
postgresql-server-dev-${PG_MAJOR}; \
16+
# Clone and build pg_ivm from source
17+
git clone --branch "v${EXT_VERSION}" --depth 1 https://github.com/sraoss/pg_ivm.git /build/pg_ivm; \
18+
cd /build/pg_ivm; \
19+
make USE_PGXS=1; \
20+
make USE_PGXS=1 install
21+
22+
FROM scratch
23+
ARG PG_MAJOR
24+
25+
# Licenses
26+
COPY --from=builder /tmp/licenses/LICENSE /licenses/pg_ivm/LICENSE
27+
28+
# Libraries
29+
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/pg_ivm* /lib/
30+
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode/
31+
32+
# Share
33+
COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/pg_ivm* /share/extension/
34+
35+
USER 65532:65532

pg_ivm/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# pg_ivm Extension
2+
3+
[pg_ivm](https://github.com/sraoss/pg_ivm) is an open-source extension
4+
that provides **Incremental View Maintenance (IVM)** for PostgreSQL, allowing
5+
materialized views to be updated incrementally when base tables change.
6+
7+
## Usage
8+
9+
### 1. Add the pg_ivm extension image to your Cluster
10+
11+
Define the `pg_ivm` extension under the `postgresql.extensions` section of
12+
your `Cluster` resource. For example:
13+
14+
```yaml
15+
apiVersion: postgresql.cnpg.io/v1
16+
kind: Cluster
17+
metadata:
18+
name: cluster-pg-ivm
19+
spec:
20+
imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
21+
instances: 1
22+
23+
storage:
24+
size: 1Gi
25+
26+
postgresql:
27+
extensions:
28+
- name: pg_ivm
29+
image:
30+
reference: ghcr.io/cloudnative-pg/pg_ivm:1.13-18-trixie
31+
```
32+
33+
### 2. Enable the extension in a database
34+
35+
You can install `pg_ivm` in a specific database by creating or updating a
36+
`Database` resource. For example, to enable it in the `app` database:
37+
38+
```yaml
39+
apiVersion: postgresql.cnpg.io/v1
40+
kind: Database
41+
metadata:
42+
name: cluster-pg-ivm-app
43+
spec:
44+
name: app
45+
owner: app
46+
cluster:
47+
name: cluster-pg-ivm
48+
extensions:
49+
- name: pg_ivm
50+
```
51+
52+
### 3. Verify installation
53+
54+
Once the database is ready, connect to it with `psql` and run:
55+
56+
```sql
57+
\dx
58+
```
59+
60+
You should see `pg_ivm` listed among the installed extensions.

pg_ivm/metadata.hcl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
metadata = {
2+
name = "pg_ivm"
3+
sql_name = "pg_ivm"
4+
image_name = "pg_ivm"
5+
shared_preload_libraries = []
6+
extension_control_path = []
7+
dynamic_library_path = []
8+
ld_library_path = []
9+
10+
versions = {
11+
bookworm = {
12+
// pg_ivm version from GitHub releases
13+
"18" = "1.13"
14+
}
15+
trixie = {
16+
// pg_ivm version from GitHub releases
17+
"18" = "1.13"
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)