mfvanek/pg-index-health-sql
حول
pg-index-health-sql is a collection of SQL queries for analyzing PostgreSQL schemas, detecting issues and promoting best practices.
البيانات والتحليلاتالنمو المقاس للنجوم
- خلال 24 ساعة
- ٠
- خلال 7 أيام
- ٠
- خلال 15 يومًا
- ٠
- خلال شهر
- جارٍ جمع السجل
تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.
README.md
الأصلpg-index-health-sql
pg-index-health-sql is a collection of SQL queries for analyzing PostgreSQL schemas, detecting issues and promoting best practices.
What is this?
pg-index-health-sql provides a curated set of raw SQL queries designed to identify common schema issues in PostgreSQL databases — such as redundant indexes, missing primary keys or inefficient table structures.
It enables lightweight, database-native analysis without requiring external libraries or frameworks, making it suitable for direct use in psql sessions, scripts, or monitoring dashboards.
Supported PostgreSQL versions
Support for previous versions of PostgreSQL
Compatibility with previous PostgreSQL versions 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.
Available checks
pg-index-health-sql allows you to detect the following problems:
- Invalid (broken) indexes (sql).
- Duplicated (completely identical) indexes (sql).
- Intersected (partially identical) indexes (sql).
- Unused indexes (sql).
- Foreign keys without associated indexes (sql).
- Indexes with null values (sql).
- Tables with missing indexes (sql).
- Tables without a primary key (sql).
- Indexes bloat (sql).
- Tables bloat (sql).
- Tables without description (sql).
- Columns without description (sql).
- Columns with json type (sql).
- Columns of serial types that are not primary keys (sql).
- Functions without description (sql).
- Indexes with boolean (sql).
- Tables with not valid constraints (sql).
- B-tree indexes on array columns (sql).
- Sequence overflow (sql).
- Primary keys with serial types (sql).
- Duplicated (completely identical) foreign keys (sql).
- Intersected (partially identical) foreign keys (sql).
- Objects with possible name overflow (sql).
- Tables are not linked to other tables (sql).
- Foreign keys with unmatched column type (sql).
- Tables with zero or one columns (sql).
- Objects whose names do not follow the naming convention (sql).
- Columns whose names do not follow the naming convention (sql).
- Primary keys with varchar columns instead of uuids (sql).
- Columns with varchar(n) type (sql).
- Indexes with unnecessary where-clause on not null column (sql).
- Primary keys that are most likely natural keys (sql).
- Columns with money type (sql).
- Indexes with a timestamp in the middle (sql).
- Columns with a timestamp type (sql).
- Tables where the primary key columns are not first (sql).
- Tables that have all columns besides the primary key that are nullable (sql).
- Columns with char(n) type (sql).
- Tables with inheritance (sql).
- Multicolumn foreign keys where at least one of the referencing columns is nullable (sql).
- Tables with no data (sql).
- Self-referenced foreign keys (sql).
- Columns with large objects type (BLOB/CLOB) (sql).
- Tables with incrementing column names (sql).
- Columns with inconsistent types (the same name but different data types) (sql).
- Unlogged tables (sql).
- Unlogged sequences (sql).
- Columns with enum type (sql).
- Cyclical relationships between tables via foreign keys (sql).
- Primary keys with integer or smallint type instead of bigint (sql).
- Nullable columns with boolean type (sql).
- Partitioned tables without partitions (sql).
Local development
Linting
SQLFluff is used to lint all SQL queries. The configuration is located in .sqlfluff.
macOS/Linux
docker run --rm \
-v "$(pwd)":/sql \
sqlfluff/sqlfluff:4.5.0 lint /sql/sql
Windows
Use cmd on Windows:
docker run --rm ^
-v "%cd%":/sql ^
sqlfluff/sqlfluff:4.5.0 lint /sql/sql
استكشف مشاريع مشابهة ومرتبطة
جارٍ التحميل…