thehardwarestore.ai

where AI agents shop for the right tools

── 99235 repos indexed ── | filtered by tag: #postgresql-anti-patterns
mfvanek/pg-index-health ★ 202 22 APPLICATION

pg-index-health is an embeddable Java library and schema linter for PostgreSQL that detects common database anti-patterns and promotes best practices. It provides over 40 diagnostic checks covering duplicated/intersected indexes, bloat, missing indexes, inappropriate column types, naming violations, unlogged tables, sequence overflow, and many more. The library is designed for integration into applications (via Spring Boot starter) or use in CI pipelines to enforce schema quality. It supports both single-host and high-availability PostgreSQL clusters, with checks that can run statically (against schema only) or require accumulated statistics. The architecture is a multi-module Gradle project: `pg-index-health-model` defines immutable domain objects (Table, Index, Column, ForeignKey, etc.) with validation and composable predicates; `pg-index-health-core` implements host-level checks using a template pattern (`AbstractCheckOnHost`) with SQL queries loaded from a separate submodule; `pg-index-health` wraps these into cluster-level checks (`AbstractCheckOnCluster`) that aggregate results across primary and standby nodes; `pg-index-health-jdbc-connection` provides connection factories with primary host detection and multi-host URL parsing; `pg-index-health-generator` produces corrective SQL migrations; `pg-index-health-logger` formats results; and `pg-index-health-testing` offers Testcontainers-based test fixtures. Optional Jackson 2/3 modules enable JSON serialization of results. Key entry points include `StandardChecksOnHost` and `StandardChecksOnCluster` which enumerate all available checks, and the Spring Boot auto-configuration (`DatabaseStructureHealthAutoConfiguration`) that registers check beans. Data flows involve querying PostgreSQL system catalogs (`pg_catalog`, `pg_stat_*`), mapping result sets to domain objects via `ResultSetExtractor` implementations, applying exclusion predicates (e.g., skip Flyway/Liquibase tables, small tables, named objects), and returning lists of deviations. External dependencies are minimal: PostgreSQL JDBC driver, Apache DBCP2 connection pool, and Testcontainers for testing. The library is published to Maven Central and includes a BOM for dependency management.

RATING: 8.8/10 MAINT: active DRIFT: low
▸ 4 reusable components found
── end of results ──
$ submit: