Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

Few questions on planning mysql table

1

56 views
  1. say I have a large table, 200 000 rows and I need to change/add column of enum type, would it work properly or would I experience problems? Should I avoid enums? example is hair color: say I have black and brown, but 200 000 rows later I decide to add blonde. (these are the fields that there will be lot of where conditions, looking up members)

  2. should email field be varchar(255)?

  3. Should IDs be always unsigned bigint?

I'm basically trying to optimize a thing or two.

EDIT: I anticipate having no more than 300 000 users, I just wonder if mediumint vs int or bigint for user ids and related ids in other tables would have any noticeable performance gain?

asked January 11, 2011 6:30 am CST
posted via StackOverflow

2 Answers

0
 
  1. enum is not a bad idea for limited set of choices like hair color, and frequent update to small table (like 200k rows) is not painful

  2. the maximum length of an email address is 320 characters. - source

  3. Unsigned Yes, if you want auto_increment, unsigned is the way to go Big int? if your table is less than 1 millions, you can set much lower than it

answered January 11, 2011 7:23 am CST
0
 
  1. 200,000 is not really that large. You shouldn't have a problem performing an ALTER TABLE on a table that small.

  2. That's what I normally use

  3. I presume you mean primary keys - unsigned bigint will allow you pretty large numbers for your primary key. Obviously using a larger data type will take up more disk space but at only 200,000 records it is not really noticeable at all.

answered January 11, 2011 7:23 am CST

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
Mysql two table query
December 30, 2010