A namespace of useful functions for inspecting PostgreSQL databases in Clojure.
The SQL query logic is based on
Queries ported to HugSQL syntax to access them as Clojure data structures.
A namespace of useful functions for inspecting PostgreSQL databases in Clojure. The SQL query logic is based on * https://github.com/heroku/heroku-pg-extras/tree/main * https://github.com/pawurb/ecto_psql_extras/tree/main * https://github.com/rustprooflabs/pgdd Queries ported to HugSQL syntax to access them as Clojure data structures.
(all-locks db)
(all-locks db params)
(all-locks db params options & command-options)
Queries with active locks
Queries with active locks
(bloat db)
(bloat db params)
(bloat db params options & command-options)
Table and index bloat in your database ordered by most wasteful
Table and index bloat in your database ordered by most wasteful
(blocking db)
(blocking db params)
(blocking db params options & command-options)
Queries holding locks other queries are waiting to be released
Queries holding locks other queries are waiting to be released
(cache-hit db)
(cache-hit db params)
(cache-hit db params options & command-options)
Index and table hit rate
Index and table hit rate
(calls db)
(calls db params)
(calls db params options & command-options)
Queries that have the highest frequency of execution
Queries that have the highest frequency of execution
(columns db)
(columns db params)
(columns db params options & command-options)
List all database column objects
List all database column objects
(connections db)
(connections db params)
(connections db params options & command-options)
Returns the list of all active database connections
Returns the list of all active database connections
(databases db)
(databases db params)
(databases db params options & command-options)
List all databases
List all databases
(db-settings db)
(db-settings db params)
(db-settings db params options & command-options)
Values of selected PostgreSQL settings
Values of selected PostgreSQL settings
Defines the critical queries and their cutoffs for the diagnose
function. The value is a map containing a predicate fn (true = pass)
to test against each result, and a description of the problem if false.
Defines the critical queries and their cutoffs for the `diagnose` function. The value is a map containing a predicate fn (true = pass) to test against each result, and a description of the problem if false.
(diagnose stats
&
{:keys [diagnostic-fns] :or {diagnostic-fns default-diagnostic-fns}})
Run assertions on stats and return a seq of result maps. Iterate through the diagnostic functions, run them, then iterate through each record, applying the predicate. Returns a flat list of result maps.
Run assertions on stats and return a seq of result maps. Iterate through the diagnostic functions, run them, then iterate through each record, applying the predicate. Returns a flat list of result maps.
(diagnose-warnings stats
&
{:keys [diagnostic-fns]
:or {diagnostic-fns default-diagnostic-fns}})
Run assertions on stats and return a seq of result maps. Iterate through the diagnostic functions, then through the results, applying the predicate. Returns a flat list of result maps, filtered to contain only actionable warnings. An empty return sequence indicates all your dianostics passed.
Run assertions on stats and return a seq of result maps. Iterate through the diagnostic functions, then through the results, applying the predicate. Returns a flat list of result maps, filtered to contain only actionable warnings. An empty return sequence indicates all your dianostics passed.
(duplicate-indexes db)
(duplicate-indexes db params)
(duplicate-indexes db params options & command-options)
Multiple indexes that have the same set of columns, same opclass, expression and predicate
Multiple indexes that have the same set of columns, same opclass, expression and predicate
(extensions db)
(extensions db params)
(extensions db params options & command-options)
Available and installed extensions
Available and installed extensions
(functions db)
(functions db params)
(functions db params options & command-options)
List all function objects in current database
List all function objects in current database
(health-check db)
(health-check db params)
(health-check db params options & command-options)
Checks the db for liveliness
Checks the db for liveliness
(index-cache-hit db)
(index-cache-hit db params)
(index-cache-hit db params options & command-options)
Calculates your cache hit rate for reading indexes
Calculates your cache hit rate for reading indexes
(index-size db)
(index-size db params)
(index-size db params options & command-options)
The size of indexes, descending by size
The size of indexes, descending by size
(index-usage db)
(index-usage db params)
(index-usage db params options & command-options)
Index hit rate (effective databases are at 99% and up)
Index hit rate (effective databases are at 99% and up)
(indexes db)
(indexes db params)
(indexes db params options & command-options)
List all index objects in current database
List all index objects in current database
(kill-all! db)
(kill-all! db params)
(kill-all! db params options & command-options)
Kill all the active database connections
Kill all the active database connections
(locks db)
(locks db params)
(locks db params options & command-options)
Queries with active exclusive locks
Queries with active exclusive locks
(long-running-queries db)
(long-running-queries db params)
(long-running-queries db params options & command-options)
All queries longer than the threshold by descending duration
All queries longer than the threshold by descending duration
(mandelbrot db)
(mandelbrot db params)
(mandelbrot db params options & command-options)
The mandelbrot set
The mandelbrot set
(null-indexes db)
(null-indexes db params)
(null-indexes db params options & command-options)
Find indexes with a high ratio of NULL values
Find indexes with a high ratio of NULL values
(outliers db)
(outliers db params)
(outliers db params options & command-options)
Queries that have longest execution time in aggregate.
Queries that have longest execution time in aggregate.
(partition-children db)
(partition-children db params)
(partition-children db params options & command-options)
List all child partitions in current database
List all child partitions in current database
(partition-parents db)
(partition-parents db params)
(partition-parents db params options & command-options)
List all parent partitions in current database
List all parent partitions in current database
(read-data-dictionary db)
Create a data dictionary summarizing all major objects in your PostgreSQL database. Respects SQL COMMMENTS, thus serves as a human-readable description of your data model.
Create a data dictionary summarizing all major objects in your PostgreSQL database. Respects SQL COMMMENTS, thus serves as a human-readable description of your data model.
(read-stats db & {:keys [limit] :or {limit 10}})
Query postgres instance for all available diagnostic information. This will invoke all of the public, read-only diagnostic queries in the namespace.
The :outliers and :calls stats require enabling the pg-stat-statements extension, otherwise they will log a warning and return nil.
Query postgres instance for all available diagnostic information. This will invoke all of the public, read-only diagnostic queries in the namespace. The :outliers and :calls stats require enabling the pg-stat-statements extension, otherwise they will log a warning and return nil.
(records-rank db)
(records-rank db params)
(records-rank db params options & command-options)
All tables and the number of rows in each ordered by number of rows descending
All tables and the number of rows in each ordered by number of rows descending
(schemas db)
(schemas db params)
(schemas db params options & command-options)
List all shemas in current database
List all shemas in current database
(seq-scans db)
(seq-scans db params)
(seq-scans db params options & command-options)
Count of sequential scans by table descending by order
Count of sequential scans by table descending by order
(table-cache-hit db)
(table-cache-hit db params)
(table-cache-hit db params options & command-options)
Calculates your cache hit rate for reading tables
Calculates your cache hit rate for reading tables
(table-indexes-size db)
(table-indexes-size db params)
(table-indexes-size db params options & command-options)
Total size of all the indexes on each table, descending by size
Total size of all the indexes on each table, descending by size
(table-size db)
(table-size db params)
(table-size db params options & command-options)
Size of the tables (excluding indexes), descending by size
Size of the tables (excluding indexes), descending by size
(tables db)
(tables db params)
(tables db params options & command-options)
List all table objects in current database
List all table objects in current database
(total-index-size db)
(total-index-size db params)
(total-index-size db params options & command-options)
Total size of all indexes in MB
Total size of all indexes in MB
(total-table-size db)
(total-table-size db params)
(total-table-size db params options & command-options)
Size of the tables (including indexes), descending by size
Size of the tables (including indexes), descending by size
(unused-indexes db)
(unused-indexes db params)
(unused-indexes db params options & command-options)
Unused and almost unused indexes
Unused and almost unused indexes
(vacuum-stats db)
(vacuum-stats db params)
(vacuum-stats db params options & command-options)
Dead rows and whether an automatic vacuum is expected to be triggered
Dead rows and whether an automatic vacuum is expected to be triggered
(views db)
(views db params)
(views db params options & command-options)
List all view objects in current database
List all view objects in current database
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close