[V4RB] difference between string & varchar
Erik Mueller-Harder
valentina-list at vermontsoftworks.com
Tue Oct 26 14:02:35 CDT 2004
On Oct 26, 2004, at 05:05, Pedro fp wrote:
> That is as I thought but it still leaves me unsure about why I'd
> choose one over the other. I take it VVarChar would result in a
> smaller data file, particularly where the string data is highly
> variable in length with a lot of it being a lot smaller than the
> maximum length, is a VString faster?
Speed:
My suspicion would be that Strings are faster than VarChars when
they're not being used wastefully. [Though after looking through my
Valentina message archive, I see that Ruslan recently said, "That was
surprise for mew few years ago, but VarChar fields work much faster of
String." So I guess my suspicion was wrong!]
Size:
VarChars will pretty much always end up saving you space when you're
not sure of the size of the data you need to store, though there is 8
bytes of overhead per VarChar field per record. FYI, there is no point
ever in defining a VarChar's maximum size as less than 504 bytes -- the
most efficient maximum sizes can be represented as (x / 2) - 8, where x
is a multiple of 1024; so 504, 1016, 1528, etc.
Reliability:
Ruslan acknowledges that VarChars are slightly more likely to become
corrupted than Strings "in hard cases" because of their complex
structure.
In the real world, I've ended up leaving Strings for VarChars in most
situations. Exceptions are few: things like 2-letter U.S. state
abbreviations and internal codes or keys whose length I'm certain of.
HTH,
-- Erik
More information about the Valentina
mailing list