1. Check size db Postgresql
SELECT pg_database.datname,
pg_database_size(pg_database.datname) AS DBSizeB,
pg_database_size(pg_database.datname)/1024 AS DBSizeKB,
pg_database_size(pg_database.datname)/1024/1024 AS DBSizeMB,
pg_database_size(pg_database.datname)/1024/1024/1024 AS DBSizeGB
FROM pg_database;
2. Check size specification db Postgresql
SELECT current_database(),
pg_database_size('teguhth') AS DBSizeB,
pg_database_size('teguhth')/1024 AS DBSizeKB,
pg_database_size('teguhth')/1024/1024 AS DBSizeMB,
pg_database_size('teguhth')/1024/1024/1024 AS DBSizeGB;
SELECT current_database(),pg_size_pretty(pg_database_size('teguhth'));
SELECT current_database(),pg_size_pretty(pg_database_size('postgres'));
SELECT current_database(),pg_size_pretty(pg_database_size(current_database()));
3. check table size
SELECT schemaname AS schema_name,current_database(),
tablename AS table_name,
pg_relation_size(schemaname || '.' || tablename) AS TableSizeB,
pg_relation_size(schemaname || '.' || tablename)/1024 AS TableSizeKB,
pg_relation_size(schemaname || '.' || tablename)/1024/1024 AS TableSizeMB,
pg_relation_size(schemaname || '.' || tablename)/1024/1024 AS TableSizeGB
FROM pg_tables
where schemaname not in ('pg_catalog','information_schema')
ORDER BY pg_relation_size(schemaname || '.' || tablename) DESC;
4. check specifi table size
SELECT current_database(),pg_relation_size('pembelian') AS table_size;
SELECT current_database(),pg_size_pretty(pg_relation_size('pembelian'));
SELECT current_database(),pg_relation_size('barang') AS table_size;
SELECT current_database(),pg_size_pretty(pg_relation_size('barang'));
SELECT pg_database.datname,
pg_database_size(pg_database.datname) AS DBSizeB,
pg_database_size(pg_database.datname)/1024 AS DBSizeKB,
pg_database_size(pg_database.datname)/1024/1024 AS DBSizeMB,
pg_database_size(pg_database.datname)/1024/1024/1024 AS DBSizeGB
FROM pg_database;
2. Check size specification db Postgresql
SELECT current_database(),
pg_database_size('teguhth') AS DBSizeB,
pg_database_size('teguhth')/1024 AS DBSizeKB,
pg_database_size('teguhth')/1024/1024 AS DBSizeMB,
pg_database_size('teguhth')/1024/1024/1024 AS DBSizeGB;
SELECT current_database(),pg_size_pretty(pg_database_size('teguhth'));
SELECT current_database(),pg_size_pretty(pg_database_size('postgres'));
SELECT current_database(),pg_size_pretty(pg_database_size(current_database()));
3. check table size
SELECT schemaname AS schema_name,current_database(),
tablename AS table_name,
pg_relation_size(schemaname || '.' || tablename) AS TableSizeB,
pg_relation_size(schemaname || '.' || tablename)/1024 AS TableSizeKB,
pg_relation_size(schemaname || '.' || tablename)/1024/1024 AS TableSizeMB,
pg_relation_size(schemaname || '.' || tablename)/1024/1024 AS TableSizeGB
FROM pg_tables
where schemaname not in ('pg_catalog','information_schema')
ORDER BY pg_relation_size(schemaname || '.' || tablename) DESC;
4. check specifi table size
SELECT current_database(),pg_relation_size('pembelian') AS table_size;
SELECT current_database(),pg_size_pretty(pg_relation_size('pembelian'));
SELECT current_database(),pg_relation_size('barang') AS table_size;
SELECT current_database(),pg_size_pretty(pg_relation_size('barang'));
No comments:
Post a Comment