Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

MySQL Indices - Performance ?

Thread Tools
 
Search this Thread
 
Old 26 November 2002, 10:24 PM
  #1  
BoxerFlat4
Scooby Regular
Thread Starter
 
BoxerFlat4's Avatar
 
Join Date: Nov 2001
Location: N Wales
Posts: 923
Received 0 Likes on 0 Posts
Post

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 ?

Old 27 November 2002, 08:33 AM
  #2  
GaryK
Scooby Regular
 
GaryK's Avatar
 
Join Date: Sep 1999
Location: Bedfordshire
Posts: 4,037
Likes: 0
Received 0 Likes on 0 Posts
Post

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]
Old 27 November 2002, 09:03 AM
  #3  
BoxerFlat4
Scooby Regular
Thread Starter
 
BoxerFlat4's Avatar
 
Join Date: Nov 2001
Location: N Wales
Posts: 923
Received 0 Likes on 0 Posts
Post

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 !
Old 27 November 2002, 09:08 AM
  #4  
GaryK
Scooby Regular
 
GaryK's Avatar
 
Join Date: Sep 1999
Location: Bedfordshire
Posts: 4,037
Likes: 0
Received 0 Likes on 0 Posts
Thumbs up

Boxer,

Yes in theory it would work, you just need to make sure you have a unique index constraint to prevent duplicates.

Gary
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Sam Witwicky
Engine Management and ECU Remapping
17
13 November 2015 10:49 AM
scoobhunter722
ScoobyNet General
52
20 October 2015 04:32 PM
FuZzBoM
Wheels, Tyres & Brakes
16
04 October 2015 09:49 PM
wrxcook
ScoobyNet General
3
29 September 2015 09:17 PM
Aaron_P85
Lighting and Other Electrical
1
28 September 2015 09:24 PM



Quick Reply: MySQL Indices - Performance ?



All times are GMT +1. The time now is 03:13 AM.