Integer values can fit into registers on a chip. Strings are always pointers
to locations in memory, and operations must be performed against string data
brought to the chip's cache, other hardware or software cache, or bussed in
from way out of town.
I've always wondered why *anyone* would recommend using strings as primary
keys. I realize they can make primary keys more "readable" if built up like
a code, and I realize vendors like Siebel issue text-based primary keys in
100-block increments to keep their primary keys unique among all tables. I
also realize the official stance from some of the mvp's on this board is to
use text-based keys (*sigh*).
But think about it. If you're comparing millions of keys to build a
Cartesian Product Table (i.e., build your query), doesn't it make more sense
to use something that can literally sit on the chip in a register and be
compared in one CMP operation (one op to move the base integer to a register,
one op to move the other integer to a register, one op to tell the chip to
compare the two, done), rather than having to point to memory for the data to
begin the comparison?
Another thing -- (long) integers are 4 bytes, period. I don't think I've
seen character-based primary keys this short. Not only that, these guys are
likely unicode, so each character is two bytes of not compressed (and if so,
perhaps requires translation before comparisons can be undertaken). Smaller
indexes = faster scans = quicker results.
Use Long Integers / Autonumbers for primary keys. Use indexes. Watch your
queries scream. And if you want, look at
www.intel.com and read about the
Intel architecture.
David Atkins, MCP