Re: [GENERAL] space-effective varchar(255)-like arrangement

From: Jan Vicherek <honza(at)ied(dot)com>
To: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] space-effective varchar(255)-like arrangement
Date: 1998-12-26 19:32:17
Message-ID: Pine.LNX.4.04.9812261417170.11035-100000@ann.ied.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hmm,

On Sat, 26 Dec 1998, Bruce Momjian wrote:

> > The main table might look like :
> > create table file (
> > name varchar(255), -- file : name; tape : name / #; tapedata : #
...
> > mjmn int2 -- if device, major / minor #
> > );
> >
> > However, the first line "name varchar(255)" will waste a lot of
> > space, since only about %0.02 files will be over 200 chars, %0.1 over 100,
> > %0.2 over 64 and %1.6 over 32.
>
> See the FAQ under character types. varcahr() does not store the max
> space, only used space.

hmm, thus if one block has 8192 bytes, and if there is 9-byte overhead
for each row, then I can store 390 rows in one block if, on average,
"names" are 10 chars in length ? echo $[ 8192 / ( 9 + 10 + 2 ) ] # = 390

If each record has variable length, pg has no way of calculating where
is start of next record, other than going through the block and summing up
lengths of varchars to determine where does next record begin, right ?
(above I use word "record" and "row" interchangeably).

Thanx a bunch,

Jan

-- Gospel of Jesus is the saving power of God for all who believe --
## To some, nothing is impossible. ##
http://Vicherek.Waterloo.on.ca/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 1998-12-26 19:39:37 Re: [GENERAL] space-effective varchar(255)-like arrangement
Previous Message Constantin Teodorescu 1998-12-26 18:54:40 Re: pgaccess 0.93 problem.