Created
June 11, 2018 09:07
-
-
Save khusnetdinov/a2e3794841ce8150e44b82d538d951b7 to your computer and use it in GitHub Desktop.
Uniques of indexes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT pg_size_pretty(SUM(pg_relation_size(idx))::BIGINT) AS SIZE, | |
(array_agg(idx))[1] AS idx1, (array_agg(idx))[2] AS idx2, | |
(array_agg(idx))[3] AS idx3, (array_agg(idx))[4] AS idx4 | |
FROM ( | |
SELECT indexrelid::regclass AS idx, (indrelid::text ||E'\n'|| indclass::text ||E'\n'|| indkey::text ||E'\n'|| | |
COALESCE(indexprs::text,'')||E'\n' || COALESCE(indpred::text,'')) AS KEY | |
FROM pg_index) sub | |
GROUP BY KEY HAVING COUNT(*)>1 | |
ORDER BY SUM(pg_relation_size(idx)) DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment