Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Surrogate Primary Keys - Integer or Character ?
Message
De
27/07/2000 13:09:03
Mike Yearwood
Toronto, Ontario, Canada
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00397596
Message ID:
00397711
Vues:
30
The performance problems should come from the key generation algorithm. Its certainly faster to increment an integer than it is to use string manipulation functions to generate a key.

This difference will only be significant in very tight loops or in intensive data entry sessions.

I have started to use integer PK's recently and now have a mixture of both in my current app. I noticed that MaxFrame starts numbering at zero. So the maximum # of integer key values it makes is 2.4 billion. However, 4 bytes is a 32 bit value which should have a maximum of 4.2 billion

Integer values use 4 bytes and range from -2147483647 to 2147483647. So maybe the generating of integer keys should start at the negative value. I don't see any problem with having negative factless / surrogate keys. If they are factless, its irrelevant what the value is except for data integrity and a unique value is a unique value no matter what the sign.

BTW, if I'm not mistaken, VMP uses all but 15 of the ASCII characters to generate a key. That means its a base 241 number (instead of base 10 (decimal), base 16 (hexadecimal) or base 256). If I'm not wrong, VMP's biggest primary key value is 812,990,017,200 (812 billion)

I'm computing that value like this...

Base 10 #'s
9,999 = (9*10^3)+(9*10^2)+(9*10)+(9)

Base 241 #'s
replicate(chr(240),4) = (240*241^4)+(240*241^3)+(240*241^2)+(240*241)+(240)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform