I know that the length is the difference, but what's the difference? Wouldn't just choosing the biggest one be the best choice? I usually use decimal(60) for everything numeric...
obviously the size means that you will create larger and smaller databases dependant on the field size for the data. Decimal would be pointless for any field with an auto increment such as an ID field (since it's positive integers only), so would be a waste of system resources
I have mediumint, unsigned for the ID fields. And decimal, unsigned for most of the big numeric fields where the numbers reach trillions, never negative. Let's say I have a field that will never have a greater value than xxx, should I choose tinyint(3), unsigned or it doesn't matter if I choose something larger? My current game site is not very well built. MySql ultilizes sometimes 100% of my server's 4GB ram.
WHAT!? Sounds like you need to do some major overhauls on your SQL queries and code structure! Yes if you know how big a field will ever be, then use the smallest possible data length for it. Why bother wasting resources if you don't need to?
If the data structures are bigger, then it will take more time for the DB server to process queries and also more data will be sent to the web server. If your site uses so much RAM then the problem probably lies elsewhere. Optimizing data structures would help, but I suggest you optimize your queries first. Read up on the "explain" command in MySQL so you can understand what's happening on the server when you do a query.
Oh, I didn't know that. What should I choose for text fields like for usernames? I usually use varchar 255. Also, for big numeric fields, what's the best option? I usually use decimal 60. Which is better decimal or bigint? Only positive values. Also, what's the point of the length option? Tinyint(1) and tinyint(3) both max value is 255... Oh and also what's the best option for text fields for usernames and larger text fields like description? I usually use TEXT for description (more text) and varchar(255) for usernames etc. Can anyone explain what's the point of the length behind the type? EDIT: The Length option only seems to make a difference for decimal fields. Decimal(3) max = 999, decimal (4) max = 9999 etc. So wouldn't decimal be the best choice for all numeric fields since I can get closer to the max amounts I need by using the length option? What's best for performance?