MySQL Indices - Performance ?
#1
Scooby Regular
Thread Starter
One for the MySQL geeks out there.....
I'm currently planning out some database's, and I've automatically designed them with the Primary Key to be INT's, so I would have..
UID = 0
UID = 1
... etc etc.
However, would I suffer any penalty for designing the Primary Key to be, say a string ? That way, I could have instead....
UID=HKS.Turbo.Thumbnail
UID=Blitz.Turbo.ThumbNail
... etc etc.
Which would be far more easier to read. Are there any issue's with doing it this way ?
I'm currently planning out some database's, and I've automatically designed them with the Primary Key to be INT's, so I would have..
UID = 0
UID = 1
... etc etc.
However, would I suffer any penalty for designing the Primary Key to be, say a string ? That way, I could have instead....
UID=HKS.Turbo.Thumbnail
UID=Blitz.Turbo.ThumbNail
... etc etc.
Which would be far more easier to read. Are there any issue's with doing it this way ?
#2
Scooby Regular
Join Date: Sep 1999
Location: Bedfordshire
Posts: 4,037
Likes: 0
Received 0 Likes
on
0 Posts
Boxer,
You will normally find databases handle integer indexes much faster than string ones. If you are using a string you would need to a create a UNIQUE index which would probably affect performance also.
Besides I always follow the rule of never using business data to form a primary key (there are some who oppose this!) but it basically means if you need to change say a part no. you dont need to re-code the db as any relationships are defined on a separate integer primary key.
HTH
Gary
[Edited by GaryK - 11/27/2002 8:34:21 AM]
You will normally find databases handle integer indexes much faster than string ones. If you are using a string you would need to a create a UNIQUE index which would probably affect performance also.
Besides I always follow the rule of never using business data to form a primary key (there are some who oppose this!) but it basically means if you need to change say a part no. you dont need to re-code the db as any relationships are defined on a separate integer primary key.
HTH
Gary
[Edited by GaryK - 11/27/2002 8:34:21 AM]
#3
Scooby Regular
Thread Starter
Cheers Gary -
So the only real objections are design ones : it should in theory work ? We're talking about a database of approx. 5,000 items at the moment, so it's not a monster, but I have normalized it so I've actually got around 8 seperate tables, each which will have 5,000 items.
I don't think performance would suffer too much, but I want to get it right in the design stage first !
So the only real objections are design ones : it should in theory work ? We're talking about a database of approx. 5,000 items at the moment, so it's not a monster, but I have normalized it so I've actually got around 8 seperate tables, each which will have 5,000 items.
I don't think performance would suffer too much, but I want to get it right in the design stage first !
Thread
Thread Starter
Forum
Replies
Last Post
Sam Witwicky
Engine Management and ECU Remapping
17
13 November 2015 10:49 AM