SQL Server Performance

Tinyint or Bit?

Discussion in 'SQL Server 2005 General Developer Questions' started by ismailadar, Nov 4, 2010.

  1. ismailadar New Member

    hi all,
    I need to create a table and it holds gender of people in a coloum. what is the best way to hold gender? With your experience whick data type is more suitable? using bit or tinyint
    Thanks in advance
  2. FrankKalis Moderator

    A tinyint consumes 1 byte. Same goes for a bit column, if it is the only bit column in that table. If you happened to have already bit columns there, they shared the same byte until this is full, then use the next byte, etc... Another alternative would be to use a char(1) column, which is also at 1 byte.Bit looks logically at little bit weird to me for storing the gender of a person. Unless, of course the column is named something like "IsWoman" or "IsMan"...
    Anyway, the possible outcomes for such an attribute are fairly limited, so that both tinyint and/or char(1) give you more than you need and since both consume the same amount of storage, the choice might be quite academic in the end.
  3. ismailadar New Member

    thank for your clear reply. the mot impotant thing is about performance espeacially when i use this coloumn for search . Which one is best?
    In my oppion tinyint provides best performance and can you share your experience on performance issue?
  4. FrankKalis Moderator

    Well, this is by no means scientifical, but I like to think that numbers perform better. If it makes a difference when dealing with a "numerical" byte vs a string "byte", I don't know...
  5. Madhivanan Moderator

    For storing gender information, it make more sense if you use CHAR(1) and store values M for Male and F for Female
  6. ismailadar New Member

    thanks for your reply but i mean storing in general not only gender information but i agree with FrankKalis about performance issue in order to store bool data.

Share This Page