This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-26
Channels
- # announcements (3)
- # babashka (28)
- # beginners (21)
- # cider (29)
- # clojars (10)
- # clojure (14)
- # clojure-australia (3)
- # clojure-europe (48)
- # clojure-nl (3)
- # clojure-sanfrancisco (4)
- # clojure-uk (54)
- # clojurescript (34)
- # cryogen (12)
- # cursive (7)
- # datomic (14)
- # devcards (1)
- # fulcro (23)
- # helix (2)
- # java (5)
- # jobs (1)
- # kaocha (15)
- # malli (13)
- # minimallist (1)
- # off-topic (8)
- # pathom (7)
- # pedestal (1)
- # rdf (10)
- # reagent (18)
- # shadow-cljs (58)
- # spacemacs (3)
- # tools-deps (1)
- # vim (6)
- # xtdb (37)
Random question, did any of you ever come across something that can parse Postgres explain/analyse output, and give some kind of programmatic insights? Indexes used, or not, etc..?
Did you already try explain/analyze tooling in PGAdmin4? It provides a visual graph and nice stats about the query plan.
At back of my mind was something like a library that could warn if an index wasn’t being used, or partially used
Oh, you can run a SQL query for that. I'm sure you could adapt this to run within your application, to give you some insight...
SELECT s.schemaname,
s.relname AS tablename,
s.indexrelname AS indexname,
pg_size_pretty(pg_relation_size(s.indexrelid)) AS index_size,
idx_scan as index_scans
FROM pg_catalog.pg_stat_user_indexes s
JOIN pg_catalog.pg_index i ON s.indexrelid = i.indexrelid
WHERE s.idx_scan = 0 -- has never been scanned
AND 0 <>ALL (i.indkey) -- no index column is an expression
AND pg_relation_size(relid) > 5 * 8192 -- has some data in the table
AND NOT i.indisunique -- is not a UNIQUE index
AND NOT EXISTS -- does not enforce a constraint
(SELECT 1 FROM pg_catalog.pg_constraint c
WHERE c.conindid = s.indexrelid)
AND s.schemaname = 'REPLACE_ME_WITH_YOUR_SCHEMA_NAME'
ORDER BY pg_relation_size(s.indexrelid) / nullif(idx_scan, 0) DESC NULLS FIRST,
pg_relation_size(i.indexrelid) DESC;
Hi everyone, I wanted to introduce myself. I'm ceo/co-founder of http://audiencerepublic.com. We are 100% clojure on the back end, and I'm looking forward to meeting more people in the clojure world 🙂