Re: Why are data types size limited?

From: Joe \ <joe_at_bftsi0.UUCP>
Date: 2000/03/19
Message-ID: <sdamlc79lul117_at_corp.supernews.com>#1/1


<eison_at_cc.gatech.edu> wrote in message news:8b3bks$qpv_at_catapult.gatech.edu...

> I am a programmer who is mostly ignorant of database theory, and have just
> started using databases. From an ignorant-user standpoint, they're great
> except for field size limitations. Character strings must be specified as
> X size maximum, with a hard limit of Y characters is the longest string
> that can be handled, unless you use this funky other binary data type that
> has its own odd and difficult syntax for working with. Why is this? Why
> can't databases be written to handle arbitrarily long strings, and grow or
> shrink all input fields as needed? I don't like having to guess how long
> somebody's e-mail address will be, and I certainly don't like having to
> check every input to make sure it's not 4000+ chars. These things would
> be more liveable if somebody could explain why the databases are written
> that way, and if there is any hope of this being fixed anytime soon.

It's mainly an implementation issue. The b-tree-based indexing scheme most RDBMS' use works best when the b-tree nodes, including the keys, fits within a disk page, however that's defined. If indexable text fields are no longer than 255 bytes, you know you can fit 14 or 15 of them into an index node when the page size is 4KB. It may be feasible to relax this limit, always use memo or long varchar fields, just index the first 255 characters, and use other tricks so that the query results still turn out right, but at the cost of speed. Who has an email address longer than 255 characters? Here's an example of one of those tricks, in pseudo-SQL:

select mytable.*
from mytable
where mytable.IndexedEmailAddress = substring(:findthisaddress, 1, 255) and mytable.FullEmailAddress = :findthisaddress

--
Joe Foster <mailto:jfoster_at_ricochet.net>  Space Cooties! <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!
Received on Sun Mar 19 2000 - 00:00:00 CET

Original text of this message