iCli is a Go CLI that reads PostgreSQL query statistics, explains the most expensive queries, identifies execution-plan bottlenecks, detects missing foreign key indexes, and reports unused indexes.
[!NOTE] 🔒 Read-Only Guarantee:
iClionly executes read-only SQL queries (SELECTmetadata andEXPLAINplan analysis). It never mutates, inserts, or deletes any data in your database.

pg_stat_statements.EXPLAIN (FORMAT JSON) and detects plan bottlenecks (e.g., sequential scans, disk sort spillage, inefficient joins).UPDATE or DELETE operations.INSERT/UPDATE performance.icli report.pg_stat_statements enabled.Enable the extension at the server level, then restart PostgreSQL:
ALTER SYSTEM SET shared_preload_libraries = 'pg_stat_statements';
After restarting PostgreSQL, enable it in the target database:
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
On a Homebrew PostgreSQL installation, restart with:
brew services restart postgresql@18
go installIf you have Go installed, you can install icli directly:
go install github.com/abhiraj-ku/pg_adv/cmd/icli@latest
Clone the repository and run the CLI with a PostgreSQL connection string.
DSN resolution order:
-d / --dsnPGDSN environment variableExamples:
git clone https://github.com/abhiraj-ku/iCli.git
cd iCli
export PGDSN="postgres://postgres@localhost:5432/postgres?sslmode=disable"
# Display interactive CLI commands menu & guide
go run ./cmd/icli
# Analyze top slow queries & execution plans
go run ./cmd/icli analyze -n 5
# Scan for unused indexes and missing foreign key indexes
go run ./cmd/icli index
go run ./cmd/icli index unused
go run ./cmd/icli index missing-fk
# Generate an instant database health summary report
go run ./cmd/icli report
Or pass the DSN explicitly:
go run ./cmd/icli analyze -d="postgres://postgres@localhost:5432/postgres?sslmode=disable"
The long-form flag is also supported:
go run ./cmd/icli analyze --dsn="postgres://postgres@localhost:5432/postgres?sslmode=disable"
Build a binary with:
go build -o icli ./cmd/icli
export PGDSN="postgres://postgres@localhost:5432/postgres?sslmode=disable"
./icli analyze
pg_stat_statements enabled in the target database-d/--dsn or PGDSNCreate a local PostgreSQL database and enable the extension:
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
Then export the connection string for local development:
export PGDSN="postgres://postgres@localhost:5432/postgres?sslmode=disable"
cmd/icli — CLI entrypoint and subcommand routing (analyze, index, report, update)internals/analyzer — execution-plan issue detection rulesinternals/db — PostgreSQL queries (pg_stat_statements, unused indexes, missing foreign key indexes)internals/health — database health stats collection (cache hit ratio, active connections)internals/report — modern Lipgloss terminal TUI renderinggo test ./...
go run ./cmd/icli
go run ./cmd/icli report
GOFLAGS=-mod=mod go run ./cmd/icli
connection refused, confirm PostgreSQL is running and the host/port are correct.pg_stat_statements is enabled and queries have been executed.-d / --dsn or export PGDSN.Prebuilt releases are available for these platforms on the GitHub Releases page:
| Platform | Architecture | Archive name pattern |
|---|---|---|
| Linux | x86_64 | icli_Linux_x86_64.tar.gz |
| macOS (Apple Silicon, M-series) | ARM 64-bit | icli_Darwin_arm64.tar.gz |
Download the archive for your platform from the Releases page, extract it, and run icli:
tar -xzf icli_Darwin_arm64.tar.gz
./icli -dsn="postgres://user:password@localhost:5432/database?sslmode=disable"
Windows and Intel macOS binaries are not included in releases.
total_time vs total_exec_time).pg_stat_statements and excludes iCli's internal telemetry queries.EXPLAIN (FORMAT JSON) plan.pg_stat_user_indexes and pg_index to find non-primary, non-unique indexes with 0 recorded scans.pg_constraint, pg_attribute, and pg_index to detect unindexed foreign keys on child tables.Go
100.0%
iCli is a Go CLI that reads PostgreSQL query statistics, explains the most expensive queries, identifies execution-plan bottlenecks, detects missing foreign key indexes, and reports unused indexes.
[!NOTE] 🔒 Read-Only Guarantee:
iClionly executes read-only SQL queries (SELECTmetadata andEXPLAINplan analysis). It never mutates, inserts, or deletes any data in your database.

pg_stat_statements.EXPLAIN (FORMAT JSON) and detects plan bottlenecks (e.g., sequential scans, disk sort spillage, inefficient joins).UPDATE or DELETE operations.INSERT/UPDATE performance.icli report.pg_stat_statements enabled.Enable the extension at the server level, then restart PostgreSQL:
ALTER SYSTEM SET shared_preload_libraries = 'pg_stat_statements';
After restarting PostgreSQL, enable it in the target database:
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
On a Homebrew PostgreSQL installation, restart with:
brew services restart postgresql@18
go installIf you have Go installed, you can install icli directly:
go install github.com/abhiraj-ku/pg_adv/cmd/icli@latest
Clone the repository and run the CLI with a PostgreSQL connection string.
DSN resolution order:
-d / --dsnPGDSN environment variableExamples:
git clone https://github.com/abhiraj-ku/iCli.git
cd iCli
export PGDSN="postgres://postgres@localhost:5432/postgres?sslmode=disable"
# Display interactive CLI commands menu & guide
go run ./cmd/icli
# Analyze top slow queries & execution plans
go run ./cmd/icli analyze -n 5
# Scan for unused indexes and missing foreign key indexes
go run ./cmd/icli index
go run ./cmd/icli index unused
go run ./cmd/icli index missing-fk
# Generate an instant database health summary report
go run ./cmd/icli report
Or pass the DSN explicitly:
go run ./cmd/icli analyze -d="postgres://postgres@localhost:5432/postgres?sslmode=disable"
The long-form flag is also supported:
go run ./cmd/icli analyze --dsn="postgres://postgres@localhost:5432/postgres?sslmode=disable"
Build a binary with:
go build -o icli ./cmd/icli
export PGDSN="postgres://postgres@localhost:5432/postgres?sslmode=disable"
./icli analyze
pg_stat_statements enabled in the target database-d/--dsn or PGDSNCreate a local PostgreSQL database and enable the extension:
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
Then export the connection string for local development:
export PGDSN="postgres://postgres@localhost:5432/postgres?sslmode=disable"
cmd/icli — CLI entrypoint and subcommand routing (analyze, index, report, update)internals/analyzer — execution-plan issue detection rulesinternals/db — PostgreSQL queries (pg_stat_statements, unused indexes, missing foreign key indexes)internals/health — database health stats collection (cache hit ratio, active connections)internals/report — modern Lipgloss terminal TUI renderinggo test ./...
go run ./cmd/icli
go run ./cmd/icli report
GOFLAGS=-mod=mod go run ./cmd/icli
connection refused, confirm PostgreSQL is running and the host/port are correct.pg_stat_statements is enabled and queries have been executed.-d / --dsn or export PGDSN.Prebuilt releases are available for these platforms on the GitHub Releases page:
| Platform | Architecture | Archive name pattern |
|---|---|---|
| Linux | x86_64 | icli_Linux_x86_64.tar.gz |
| macOS (Apple Silicon, M-series) | ARM 64-bit | icli_Darwin_arm64.tar.gz |
Download the archive for your platform from the Releases page, extract it, and run icli:
tar -xzf icli_Darwin_arm64.tar.gz
./icli -dsn="postgres://user:password@localhost:5432/database?sslmode=disable"
Windows and Intel macOS binaries are not included in releases.
total_time vs total_exec_time).pg_stat_statements and excludes iCli's internal telemetry queries.EXPLAIN (FORMAT JSON) plan.pg_stat_user_indexes and pg_index to find non-primary, non-unique indexes with 0 recorded scans.pg_constraint, pg_attribute, and pg_index to detect unindexed foreign keys on child tables.Go
100.0%