Re: [HACKERS] varchar/char size

From: The Hermit Hacker <scrappy(at)hub(dot)org>
To: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
Cc: Mattias Kregert <matti(at)algonet(dot)se>, hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] varchar/char size
Date: 1998-01-09 17:56:17
Message-ID: Pine.NEB.3.95.980109124918.16290G-100000@hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 9 Jan 1998, Bruce Momjian wrote:

> > Is CHAR padded on disk? Of course it should be padded for
> > representation, but for storage, couldn't it be stored just like
> > TEXT or VARCHAR? Before storing, it could be trimmed, and when
> > read from storage, it could be padded with spaces on the right.
>
> Well, traditionally, CHAR() is fixed length, and VARCHAR() is variable.
> This is how Ingres and Informix handle it.

But how do we store this to the file system? If I setup a table
with a char(20), and one of the records has a value of "a", does it then
write 1 byte to the file system, or does it write 1 byte ("a") + 19 bytes
("")?

If the second, is there a reason why, as far as writing to the
file system is concerned, char() can't be treated like varchar()? I'd
imagine you could save one helluva lot of "disk space" by doing that, no?

Then again, thinkiing of it that way, I may as well just use
varchar() instead, right?

See, this is what *really* gets me lost...I use text for
everything, since I really haven't got a clue as to *why* I'd want to use
either char() or varchar() instead...

Now, from what I *think* I recall you stating, char() and
varchar() are more for backwards compatibility? Compatibility with other
SQL engines? If so...as long as we have a type char(), does our backend
representation have to be any different between char() and text?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message The Hermit Hacker 1998-01-09 18:10:20 Re: [HACKERS] Disk block size issues.
Previous Message Bruce Momjian 1998-01-09 17:34:37 Re: [HACKERS] column labels now with obligatory 'as'