anek.pg-index-health-core.0.13.1.source-code.CONTRIBUTING.md Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pg-index-health-core Show documentation
Show all versions of pg-index-health-core Show documentation
pg-index-health-core is a Java library for analyzing and maintaining indexes and tables health in PostgreSQL databases on a specific host.
The newest version!
## Implementing a new check
### Write a new SQL query
Each database structure check starts with an SQL query to the pg_catalog.
1. [SQLFluff](https://github.com/sqlfluff/sqlfluff) is used as a linter for all sql queries
2. All queries must be schema-aware, i.e. we filter out database objects on schema basis:
```sql
where
nsp.nspname = :schema_name_param::text
```
3. All tables and indexes names in the query results must be schema-qualified.
We use `::regclass` on `oid` for that.
```sql
select
psui.relid::regclass::text as table_name,
psui.indexrelid::regclass::text as index_name,
```
4. All query results must be ordered in some way.
5. Do not forget to update `README.md`.