Thread: int performance

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Posts
    28
    Rep Power
    0

    int performance


    Now, this might be considered a dumb question, but I'm one of those people that can't do something unless I feel it's being done the right (best) way.

    I know (or at least I've heard) mysql performance is better when a length is specified for a type value.
    ie. varchar(32), int(50), etc...

    I've also heard that the closer the alloted length is to a required length, the better the performance.
    ie. storing numbers 1 - 9, int(1) would be better than int(11).

    Is there a performance difference (or is it good habit) to use types like mediumint in place of int(5)?

    When I create a database to hold product categories, for example, I use tinyint -- no length specified -- if I know there will be fewer than 100 categories. However, I have seen people use int(5), int (6), or just plan int. It seems like a waste if that kind of length isn't needed, but maybe I just don't understand it.
    Please comment.
  2. #2
  3. No Profile Picture
    hmm...
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    Nashville
    Posts
    50
    Rep Power
    17

    You're Right


    Why waste the space. If you have a large amount of rows in your tables, the difference in your database size will be significant.
    1 million rows... Save eight bits in each...Do the math.
    I personally doubt that any searches would have any significant decrease in speed if you used int(11) instead of int(4).

IMN logo majestic logo threadwatch logo seochat tools logo