[thelist] mysql primary key multiple columns

rudy limeback r937 at interlog.com
Tue Aug 29 23:01:49 CDT 2000


> instead of a multiple column pk try using
> a multi-column unique constraint --it may be faster....

hi scott

sorry for the delay, i originally answered this earlier today but it
bounced -- but i got a really sweet letter from postfix himself!

just got back from spending the day at the ex (www.theex.com) with the
kids -- there's this one ride, they lift you straight up about a hunnert
and fifty feet, then just drop you...  total free fall...  must hit a
couple of g's in the last twenty feet as it brakes... don't go on it right
after eating...

anyhow, to business...

a unique constraint may be faster than a pk in ensuring uniqueness, but if
so, only marginally (i'm guessing)

however, it's *not* faster if what you want is relational integrity

let me 'splain...

if what you want is uniqueness, a unique works key great

unfortunately, so does declaring a pk -- see, people have used the pk for
uniqueness so often that its real purpose is virtually unknown

so i guess, scott, your advice is fine, assuming that the reason for
wanting a pk was this, um, side-benefit, that it's (by definition) unique

but if what you want is what a pk is for, then no way a unique index is
faster -- heck, look at all the triggers and stored procs you'd have to
write

and they would not likely be faster than the database's builtin relational
integrity

sorry to be the pedant around here, but somebody's gotta do it

;o)

rudy
r937.com







More information about the thelist mailing list