Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Char vs Varchar in Index
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00843921
Message ID:
00844043
Views:
26
>>Hi Mike
>>
>>>We are putting together a database which will utilise 22 character UIDs as the primary key on most tables. Has anyone done any tests to see if there is a significant performance penalty for using varchar as the datatype for the primary and foreign keys rather than char?
>>
>>As a general rule, the fastest and most efficient primary key in any database (SQL Server and ORacle included) is an INTEGER. CHAR is also invariably faster than VARCHAR and if you must use a 22-character field as the primary key that would be the better option. However I would still recommend that you keep the primary key on the table as an auto-generated integer since that will generally give you the best performance when dealing with inserts, updates and deletes.
>
>Andy,
>Why is CHAR faster than VARCHAR? Have you run tests on this yourself? Or did you see an article by someone who did? I'm curious.
>
>Regards.

Larry,

I'm not Andy, but I'll take a SWAG. A VARCHAR can contain 1 to n characters where n equals the maximum field size. A CHAR is fixed. I would think that resolving a variable length expression would be slower than a fixed length expression.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform