Re: feature request - datum_compute_size and datum write_should be public

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Jim Nasby <jim(at)nasby(dot)net>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, "heikki(dot)linnakangas" <heikki(dot)linnakangas(at)iki(dot)fi>, Jeff Davis <pgsql(at)j-davis(dot)com>
Subject: Re: feature request - datum_compute_size and datum write_should be public
Date: 2012-02-02 03:11:16
Message-ID: 14896.1328152276@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Excerpts from Jim Nasby's message of mi feb 01 20:47:05 -0300 2012:
>> I'm not certain this in what Pavel is referring to, but I have often wished that I could pass something like an array into a function and have the function tell me exactly how much space that would require on-disk. It's pretty easy to figure that out for things like varchar and numeric, but doing so for arrays or composite types requires pretty detailed knowledge of PG internals.

> I think you can just use pg_column_size on a composite datum (such as a
> ROW() construct) and it will give you the right number.

If it's a freshly-computed value, pg_column_size will give you the size
of the "raw" datum. The actual size on disk might be less due to
compression, but I don't think we give you any way to find that out
short of actually storing it in a table. Note that the rangetype
internal functions Pavel suggests we should expose won't give you the
latter either.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-02-02 03:57:48 Re: spgist text_ops and LIKE
Previous Message Shigeru Hanada 2012-02-02 02:32:03 Re: pgsql_fdw, FDW for PostgreSQL server