Re: Tuple data

From: Hannu Krosing <hannu(at)tm(dot)ee>
To: Michael Richards <miker(at)interchange(dot)ca>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Tuple data
Date: 2000-12-16 20:20:50
Message-ID: 3A3BCEA2.BC6FBA1B@tm.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Michael Richards wrote:
>
> > That's not right --- AFAIR there is no length in the tuple data. You
> > must use the length from the 'page item' pointer that points to this
> > tuple if you want to know the total tuple length.
>
> Oops, I meant attribute length...
>
> > If you were testing with tables containing single varlena columns, then
> > you may have seen the varlena datum's length word and taken it for total
> > length of the tuple --- but it's only total length of that one column.
>
> Yes, I obviously had assumed that this length was common to all types (I was
> testing with varchars before).
>
> I presume then that I get the sizes based on some system tables. What query
> should I run to give me the layout (in the order it's on disk) and the size
> of each non-varlen attribute?

select * from pg_attribute
where attrelid = (select oid from pg_class where relname = 'tablename')
order by attnum;

then look up types by attypid to find the types or just look at attlen
==-1 for varlena types

select * from pg_type where oid = 23; -- gives info for int type
select * from pg_type where oid = 1043; -- varchar

--------
Hannu

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-12-16 20:29:51 Re: Tuple data
Previous Message Bruce Momjian 2000-12-16 20:16:22 7.1 features list