문제

I've been a bit lazy lately and have been generating gigabytes of PostGis database records much of which I don't need anymore. I'm beginning to think of cleaning it out a bit, but want to determine how many bytes these records are taking up.

I'm using rails, so if I could call a method or SQL snippet on an already selected group of records to determine the size of said records in bytes this would be very helpful.

도움이 되었습니까?

해결책

For the table:

SELECT  pg_size_pretty(pg_total_relation_size('name_of_tbl'));

For a particular table row and/or column in it:

SELECT pg_column_size(t) AS row_size_on_disk
       pg_column_size(t.column1) AS column1_size_on_disk
FROM   tbl t
WHERE  tbl_id = ?;

See:

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top