DB design document

David Merrill dmerrill@lupercalia.net
Fri, 15 Dec 2000 11:30:22 -0500


On Fri, Dec 15, 2000 at 09:51:28AM -0600, Patrick Spinler wrote:
> David Merrill wrote:
> > 
> > On Thu, Dec 14, 2000 at 09:54:44AM -0600, Patrick Spinler wrote:
> > > In short, if you plan on having updatable data, use varchar() columns,
> > > for which most databases preallocate space in the record.  This means
> > > some wastage of data storage, but you get a lot of positive performance
> > > boosts because of it.
> > 
> > I think you have this backwards. varchar means "variable length char",
> > while 'char' or sometimes 'text' is fixed length. By variable vs fixed
> > I mean how it is stored on disk, not the constraints on valid entries.
> > 
> 
> In the systems that I've looked at, both varchar() and char() allocate
> fixed length fields on disk.  The difference is only that varchar()
> tracks how much actual data is in the field, typically through some form
> of count field associated with the varchar().
> 
> Here's an example of how a varchar and a char field containing the same
> data might actually by stored on disk with the same data
> 
> Char(20) field containing "this is foobar"
> 
>  |this is foobar      |       | - indicates field boundry
> 
> Varchar(20) field containing "this is foobar"
> 
>  |000E|this is foobar      |    000E would actually be binary ...

Hearing this, David was enlightened.

I'm taking a bit of a time out from schema design to study Postgres
and its mechanisms and data types. I need to know them specifically
before I can fine-tune the data types.

-- 
Dr. David C. Merrill                     http://www.lupercalia.net
Linux Documentation Project                dmerrill@lupercalia.net
Collection Editor & Coordinator            http://www.linuxdoc.org
                                       Finger me for my public key

There are three kinds of people: men, women, and unix.