on 12/31/01 12:34, Frank Bitterlich at bitterlich .at. gsco DOT de wrote:
Hi Frank,
> I guess it's time for me to ask something I have been wondering about > for quite some time now. What exactly is the difference between VarChar > and String fields? And how do I decide which one to use? I have often > read things like "..in this case VarChar could be faster than String", > or vice versa. But what means "could"? What exectly do I need to know to > use the most effective one?
> I mean, maybe for large text fields, VarChar is faster when reading, but > String is faster when inserting/updtaing, or the like? > > Until today, I'm always guessing which one to use... can you shed some > light on this?
I believe this is described in ValentinaKernel.pdf and in FAQs.
In short once again:
*** String -- is FIXED size string.
string[N] allocate on disk exactly N+1 bytes. ALWAYS.
This string is good for range from 2 to 20-50 bytes. This type is perfect if ALL your records has value N bytes. For big N most probably you will get a lots of not used space. Look, if you set String[200] then empty string still will use 200 bytes on disk.
*** VarChar[N] use 4 bytes + N (btw, this was my mistake, must be 2+N) So empty VarChar will use only 4 bytes on disk.
As you see VarChar can effectively store values that VERY differ in size one from other.
IT is obvious that VarChar is not good for small string, i.e. VarChar[5] is worse than String[5].
I don't know exact rule to choose one. For example URL can be short as apple.com and long as CGI string, so for URL it is good to choose VarChar[504].
-- Best regards, Ruslan Zasukhin
------------------------- Paradigma.
e-mail: ruslan@paradigmasoft.com web : http://www.paradigmasoft.com
To subscribe to the Valentina mail list send a letter to valentina-on .at. lists DOT macserve.net ©2001 Ruslan Zasukhin |