|
| 1 | +# pg_qualstats |
| 2 | +<!-- |
| 3 | +SPDX-FileCopyrightText: Copyright © contributors to CloudNativePG, established as CloudNativePG a Series of LF Projects, LLC. |
| 4 | +SPDX-License-Identifier: Apache-2.0 |
| 5 | +--> |
| 6 | + |
| 7 | +[pg_qualstats](https://github.com/powa-team/pg_qualstats) is a PostgreSQL |
| 8 | +extension that collects statistics about predicates (quals) found in |
| 9 | +`WHERE` clauses and `JOIN` conditions. It can be used to identify missing |
| 10 | +indexes and understand query workload patterns. For more information, see the |
| 11 | +[official documentation](https://powa.readthedocs.io/en/latest/components/pg_qualstats.html). |
| 12 | + |
| 13 | +## Usage |
| 14 | + |
| 15 | +The `pg_qualstats` extension must be loaded via `shared_preload_libraries` |
| 16 | +to hook into the query executor and collect predicate statistics. |
| 17 | + |
| 18 | +### 1. Add the pg_qualstats extension image to your Cluster |
| 19 | + |
| 20 | +Define the `pg-qualstats` extension under the `postgresql.extensions` section |
| 21 | +of your `Cluster` resource. For example: |
| 22 | + |
| 23 | +```yaml |
| 24 | +apiVersion: postgresql.cnpg.io/v1 |
| 25 | +kind: Cluster |
| 26 | +metadata: |
| 27 | + name: cluster-pg-qualstats |
| 28 | +spec: |
| 29 | + imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie |
| 30 | + instances: 1 |
| 31 | + |
| 32 | + storage: |
| 33 | + size: 1Gi |
| 34 | + |
| 35 | + postgresql: |
| 36 | + shared_preload_libraries: |
| 37 | + - pg_qualstats |
| 38 | + extensions: |
| 39 | + - name: pg-qualstats |
| 40 | + image: |
| 41 | + # renovate: suite=trixie-pgdg depName=postgresql-18-pg-qualstats |
| 42 | + reference: ghcr.io/cloudnative-pg/pg-qualstats:2.1.3-18-trixie |
| 43 | +``` |
| 44 | +
|
| 45 | +### 2. Enable the extension in a database |
| 46 | +
|
| 47 | +You can install `pg_qualstats` in a specific database by creating or updating a |
| 48 | +`Database` resource. For example, to enable it in the `app` database: |
| 49 | + |
| 50 | +```yaml |
| 51 | +apiVersion: postgresql.cnpg.io/v1 |
| 52 | +kind: Database |
| 53 | +metadata: |
| 54 | + name: cluster-pg-qualstats-app |
| 55 | +spec: |
| 56 | + name: app |
| 57 | + owner: app |
| 58 | + cluster: |
| 59 | + name: cluster-pg-qualstats |
| 60 | + extensions: |
| 61 | + - name: pg_qualstats |
| 62 | + # renovate: suite=trixie-pgdg depName=postgresql-18-pg-qualstats |
| 63 | + version: '2.1.3' |
| 64 | +``` |
| 65 | + |
| 66 | +### 3. Verify installation |
| 67 | + |
| 68 | +Once the database is ready, connect to it with `psql` and run: |
| 69 | + |
| 70 | +```sql |
| 71 | +\dx |
| 72 | +``` |
| 73 | + |
| 74 | +You should see `pg_qualstats` listed among the installed extensions. |
| 75 | + |
| 76 | +## Contributors |
| 77 | + |
| 78 | +This extension is maintained by: |
| 79 | + |
| 80 | +- Erling Kristiansen (@egkristi) |
| 81 | + |
| 82 | +The maintainers are responsible for: |
| 83 | + |
| 84 | +- Monitoring upstream releases and security vulnerabilities. |
| 85 | +- Ensuring compatibility with supported PostgreSQL versions. |
| 86 | +- Reviewing and merging contributions specific to this extension's container |
| 87 | + image and lifecycle. |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +## Licenses and Copyright |
| 92 | + |
| 93 | +This container image contains software that may be licensed under various |
| 94 | +open-source licenses. |
| 95 | + |
| 96 | +All relevant license and copyright information for the `pg_qualstats` extension |
| 97 | +and its dependencies are bundled within the image at: |
| 98 | + |
| 99 | +```text |
| 100 | +/licenses/ |
| 101 | +``` |
| 102 | + |
| 103 | +By using this image, you agree to comply with the terms of the licenses |
| 104 | +contained therein. |
0 commit comments