Re: How to evaluate disk space needed by a table

Поиск
Список
Период
Сортировка
От Stephen Frost
Тема Re: How to evaluate disk space needed by a table
Дата
Msg-id 20130528044204.GY8597@tamriel.snowman.net
обсуждение исходный текст
Ответ на How to evaluate disk space needed by a table  (高健 <luckyjackgao@gmail.com>)
Список pgsql-general
* 高健 (luckyjackgao@gmail.com) wrote:
> So , Is there any  method to correctly evaluate  disk space one table will
> need,
> given the table's column data types and , estimated record numbers ?

The simplest might be to do exactly what you did- create the table and
then check the size with a subset of records.  It won't be exactly
linear from there but it'd provide a good estimate.

Otherwise, you need to consider the various additional fields which
PostgreSQL adds to every tuple to keep track of visibility and other
information.  Then you have to add in the page header and the other bits
of the tuple header beyond the system columns.  Lastly, you need to
figure out how many tuples will actually fit on a page based on their
size, because there will be gaps if the tuple doesn't fit exactly into
the remaining space in the page.

btw, there are helper functions to get disk usage-
pg_total_relation_size() and pg_relation_size() come to mind, though
there are also others.

    Thanks,

        Stephen

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: 高健
Дата:
Сообщение: How to evaluate disk space needed by a table
Следующее
От: Nikhil G Daddikar
Дата:
Сообщение: How to check if Postgresql files are OK