Re: Data Type Size Calculation

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: Data Type Size Calculation
Дата
Msg-id YgqkmS90aVAwoys3@momjian.us
обсуждение исходный текст
Ответ на Data Type Size Calculation  (PG Doc comments form <noreply@postgresql.org>)
Ответы Re: Data Type Size Calculation  (Troy Frericks <troy.frericks@gmail.com>)
Список pgsql-docs
On Fri, Feb 11, 2022 at 08:12:08PM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
> 
> Page: https://www.postgresql.org/docs/13/datatype-numeric.html
> Description:
> 
> > The actual storage requirement is two bytes for each group of four decimal
> digits, plus three to eight bytes overhead.
> 
> Please describe what 'overhead' means. 
> 
> I'd like to be able to calculate the data size of NUMBER(19,4). I can
> calculate 2 bytes per 4 digits... with 19 digits, I have 5 groups of 4
> digits, 
> 
> so the data length I seek is 5 bytes + overhead... then I'm left hanging.
> :(

Well, you can create it and then call pg_column_size():

    CREATE TABLE test (x NUMERIC(19,4));
    
    SELECT pg_column_size('test.x');
     pg_column_size
    ----------------
                  7

If you want more details, you will need to look at the source code.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  If only the physical world exists, free will is an illusion.




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

Предыдущее
От: PG Doc comments form
Дата:
Сообщение: Data Type Size Calculation
Следующее
От: PG Doc comments form
Дата:
Сообщение: tutorial problem solution requires that problem is already fixed