DB design document

Patrick Spinler spinler.patrick@mayo.edu
Fri, 15 Dec 2000 09:51:28 -0600


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 ...

-- Pat

-- 
      This message does not represent the policies or positions
	     of the Mayo Foundation or its subsidiaries.
  Patrick Spinler			email:	Spinler.Patrick@Mayo.EDU
  Mayo Foundation			phone:	507/284-9485