List:Internals« Previous MessageNext Message »
From:David Hanney Date:April 30 2002 2:19pm
Subject:Re: foreign key / duplcation / optimization
View as plain text  
At 08:29 29/04/02 -0700, Jeremy Zawodny wrote:
>On Mon, Apr 29, 2002 at 01:06:02PM +0100, David Hanney wrote:
>
> > I've got a nice fat varchar(255) primary key who's content is
> > duplicated (as a foreign key) in many other tables.  I hope MySQL
> > optimizes away that duplication internally.
>
>Not as much as you're probably hoping for.  Consider making an MX5()
>hash of the string and using that instead.  It'll buy you a lot of
>space.

I could take some kind of hash.

Better yet I could add an
"id BIGINT NOT NULL auto_increment"
column and use that for forming relationships
(instead of using the "varchar(255)").

But there'd be a one-to-one mapping between the
auto_increment and the varchar ... in information-terms it adds nothing.
The auto_increment would only be there for implementation efficiency.

This seems like a database task, not an application task.
I don't want to do it in both places so that's why I'm curious
as to what the database actually does.

Any info appreciated!

DH

Thread