Home Tools Prompts SQL Index Fragmentation Audit
Coding advanced Featured

SQL Index Fragmentation Audit

Provides SQL maintenance scripts and guides for auditing index fragmentation.

Works with: all
Prompt
Act as a senior database reliability engineer. Write a maintenance query and performance audit guide in SQL for detecting and rebuilding fragmented indexes on [DATABASE_TYPE] tables to restore query speed.
Example Output
SELECT schemaname, tablename, indexname, idx_scan
FROM pg_stat_user_indexes
WHERE idx_scan = 0;
Run REINDEX INDEX CONCURRENTLY during low-traffic maintenance windows to eliminate fragmentation without blocking live writes.
#sql #database #performance #coding