1

Is there any way to get this query to return the index size as BYTES?

SELECT 
 relid::regclass AS table, 
 indexrelid::regclass AS index,
 pg_size_pretty(pg_relation_size(indexrelid::regclass)) AS index_size, 
 idx_tup_read, 
 idx_tup_fetch, 
 idx_scan
FROM 
 pg_stat_user_indexes 
 JOIN pg_index USING (indexrelid) 
WHERE 
 idx_scan = 0 
 AND indisunique IS FALSE;

Currently it shows BYTES/KB/MB and GB...

Michael Green
25.3k13 gold badges54 silver badges100 bronze badges
asked May 9, 2016 at 3:44

1 Answer 1

1

Just remove pg_size_pretty from the query:

SELECT 
 relid::regclass AS table, 
 indexrelid::regclass AS index,
 pg_relation_size(indexrelid::regclass) AS index_size, 
answered May 9, 2016 at 6:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.