Giter Club home page Giter Club logo

pg-index-health's Introduction

pg-index-health

pg-index-health is a Java library for analyzing and maintaining indexes and tables health in PostgreSQL databases.

Java CI Maven Central License: Apache 2.0 javadoc codecov

Bugs Vulnerabilities Code Smells Lines of Code Coverage

Mutation testing badge

Supported PostgreSQL versions

PostgreSQL 12 PostgreSQL 13 PostgreSQL 14 PostgreSQL 15 PostgreSQL 16

Support for previous versions of PostgreSQL

Compatibility with PostgreSQL versions 9.6, 10 and 11 is no longer guaranteed, but it is very likely.
We focus only on the currently maintained versions of PostgreSQL.
For more information please see PostgreSQL Versioning Policy.

Supported Java versions

Supports Java 11 and above
For Java 8 compatible version take a look at release 0.7.0 and lower

Available checks

pg-index-health allows you to detect the following problems:

  1. Invalid (broken) indexes (sql).
  2. Duplicated (completely identical) indexes (sql).
  3. Intersected (partially identical) indexes (sql).
  4. Unused indexes (sql).
  5. Foreign keys without associated indexes (sql).
  6. Indexes with null values (sql).
  7. Tables with missing indexes (sql).
  8. Tables without primary key (sql).
  9. Indexes bloat (sql).
  10. Tables bloat (sql).
  11. Tables without description (sql).
  12. Columns without description (sql).
  13. Columns with json type (sql).
  14. Columns of serial types that are not primary keys (sql).
  15. Functions without description (sql).
  16. Indexes with boolean (sql).
  17. Tables with not valid constraints (sql).
  18. B-tree indexes on array columns (sql).

For raw sql queries see pg-index-health-sql project.

How does it work?

pg_index_health utilizes the Cumulative Statistics System (formerly known as PostgreSQL's statistics collector).
You can call pg_stat_reset() on each host to reset all statistics counters for the current database to zero but the best way to do it is to use DatabaseManagement::resetStatistics() method.

Installation

Using Gradle:

implementation 'io.github.mfvanek:pg-index-health:0.11.1'
with Kotlin DSL
implementation("io.github.mfvanek:pg-index-health:0.11.1")

Using Maven:

<dependency>
  <groupId>io.github.mfvanek</groupId>
  <artifactId>pg-index-health</artifactId>
  <version>0.11.1</version>
</dependency>

Articles and publications

How to use

There are three main scenarios of using pg-index-health in your projects:

  • unit\functional testing;
  • collecting indexes health data and monitoring bloat;
  • analysis of database configuration.

All these cases are covered with examples in the pg-index-health-demo project.

Integration with Spring Boot

There is a Spring Boot starter pg-index-health-test-starter for unit/integration testing as well.
More examples you can find in pg-index-health-spring-boot-demo project.

Starter installation

Using Gradle:

testImplementation 'io.github.mfvanek:pg-index-health-test-starter:0.11.1'
with Kotlin DSL
testImplementation("io.github.mfvanek:pg-index-health-test-starter:0.11.1")

Using Maven:

<dependency>
    <groupId>io.github.mfvanek</groupId>
    <artifactId>pg-index-health-test-starter</artifactId>
    <version>0.11.1</version>
    <scope>test</scope>
</dependency>

Spring Boot compatibility

Spring Boot Min JDK pg-index-health-test-starter
2.4.x 8 0.3.x — 0.4.x
2.5.x 8 0.5.x — 0.6.x
2.6.x 8 0.7.x
2.7.x 11 0.8.x — 0.11.x

Spring Boot 3 compatibility

Questions, issues, feature requests and contributions

  • If you have any question or a problem with the library, please file an issue.
  • Contributions are always welcome! Please see contributing guide for more details.
  • We utilize Testcontainers for testing pg-index-health. So you need to have Docker installed on your machine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.