> I have a table with (char)Username attribute which is the primary
> key of the table and also acts as a foreign key in many other tables.
>
> My question is if the queries would be faster if i used a numeric
> value for the primary key?
Integers would be faster, but the question is really
by *how much*.
If the Username field is long (though I presume it
isn't) and/or you have many rows, the index will take
up more space, and might not fit in memory (and will
thus need to read from disk during queries).
If the field is not declared BINARY, MySQL will do the
search in a case-insensitive manner, which will
of course be *very* slow compared to both a BINARY
char column and an integer column.
All that aside, keeping the Username column as the
primary key may be more logical and easier to maintain
in the long run, and by introducing an integer key,
you may be giving up simplicity for the sake of a
potentially very small gain in speed.
/ Carsten
--
Carsten H. Pedersen
keeper and maintainer of the bitbybit.dk MySQL FAQ
http://www.bitbybit.dk/mysqlfaq
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php