Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 948239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:12:41+00:00 2026-05-15T23:12:41+00:00

I’m learning about the usage of datatypes for databases. For example: Which is better

  • 0

I’m learning about the usage of datatypes for databases.

For example:

  • Which is better for email? varchar[100], char[100], or tinyint (joking)
  • Which is better for username? should I use int, bigint, or varchar?
    Explain. Some of my friends say that if we use int, bigint, or another numeric datatype it will be better (facebook does it). Like u=123400023 refers to user 123400023, rather then user=thenameoftheuser. Since numbers take less time to fetch.
  • Which is better for phone numbers? Posts (like in blogs or announcments)? Or maybe dates (I use datetime for that)? maybe some have make research that would like to share.
  • Product price (I use decimal(11,2), don’t know about you guys)?
  • Or anything else that you have in mind, like, "I use serial datatype for blablabla".

Why do I mention innodb specifically?

Unless you are using the InnoDB table
types (see Chapter 11, "Advanced
MySQL," for more information), CHAR
columns are faster to access than
VARCHAR.

Inno db has some diffrence that I don’t know.
I read that from here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:12:42+00:00Added an answer on May 15, 2026 at 11:12 pm

    Brief Summary:

    (just my opinions)

    1. for email address – VARCHAR(255)
    2. for username – VARCHAR(100) or VARCHAR(255)
    3. for id_username – use INT (unless you plan on over 2 billion users in you system)
    4. phone numbers – INT or VARCHAR or maybe CHAR (depends on if you want to store formatting)
    5. posts – TEXT
    6. dates – DATE or DATETIME (definitely include times for things like posts or emails)
    7. money – DECIMAL(11,2)
    8. misc – see below

    As far as using InnoDB because VARCHAR is supposed to be faster, I wouldn’t worry about that, or speed in general. Use InnoDB because you need to do transactions and/or you want to use foreign key constraints (FK) for data integrity. Also, InnoDB uses row level locking whereas MyISAM only uses table level locking. Therefore, InnoDB can handle higher levels of concurrency better than MyISAM. Use MyISAM to use full-text indexes and for somewhat less overhead.

    More importantly for speed than the engine type: put indexes on the columns that you need to search on quickly. Always put indexes on your ID/PK columns, such as the id_username that I mentioned.

    More details:

    Here’s a bunch of questions about MySQL datatypes and database design (warning, more than you asked for):

    • What DataType should I pick?

    • Table design question

    • Enum datatype versus table of data in MySQL?

    • mysql datatype for telephne number and address

    • Best mysql datatype for grams, milligrams, micrograms and kilojoule

    • MySQL 5-star rating datatype?

    And a couple questions on when to use the InnoDB engine:

    • MyISAM versus InnoDB

    • When should you choose to use InnoDB in MySQL?

    I just use tinyint for almost everything (seriously).

    Edit – How to store “posts:”

    Below are some links with more details, but here’s the short version. For storing “posts,” you need room for a long text string. CHAR max length is 255, so that’s not an option, and of course CHAR would waste unused characters versus VARCHAR, which is variable length CHAR.

    Prior to MySQL 5.0.3, VARCHAR max length was 255, so you’d be left with TEXT. However, in newer versions of MySQL, you can use VARCHAR or TEXT. The choice comes down to preference, but there are a couple differences. VARCHAR and TEXT max length is now both 65,535, but you can set you own max on VARCHAR. Let’s say you think your posts will only need to be 2000 max, you can set VARCHAR(2000). If you every run into the limit, you can ALTER you table later and bump it to VARCHAR(3000). On the other hand, TEXT actually stores its data in a BLOB (1). I’ve heard that there may be performance differences between VARCHAR and TEXT, but I haven’t seen any proof, so you may want to look into that more, but you can always change that minor detail in the future.

    More importantly, searching this “post” column using a Full-Text Index instead of LIKE would be much faster (2). However, you have to use the MyISAM engine to use full-text index because InnoDB doesn’t support it. In a MySQL database, you can have a heterogeneous mix of engines for each table, so you would just need to make your “posts” table use MyISAM. However, if you absolutely need “posts” to use InnoDB (for transactions), then set up a trigger to update the MyISAM copy of your “posts” table and use the MyISAM copy for all your full-text searches.

    See bottom for some useful quotes.

    • MySQL Data Type Chart (outdated)

    • MySQL Datatypes (outdated)

    • Chapter 10. Data Types (better details)

    • The BLOB and TEXT Types (1)

    • 11.9. Full-Text Search Functions (2)

    • 10.4.1. The CHAR and VARCHAR Types (3)

    (3) “Values in VARCHAR columns are
    variable-length strings. The length
    can be specified as a value from 0 to
    255 before MySQL 5.0.3, and 0 to
    65,535 in 5.0.3 and later versions.

    Before MySQL 5.0.3, if you need a data
    type for which trailing spaces are not
    removed, consider using a BLOB or TEXT
    type.

    When CHAR values are stored, they are
    right-padded with spaces to the
    specified length. When CHAR values are
    retrieved, trailing spaces are
    removed.

    Before MySQL 5.0.3, trailing spaces
    are removed from values when they are
    stored into a VARCHAR column; this
    means that the spaces also are absent
    from retrieved values.”

    Lastly, here’s a great post about the pros and cons of VARCHAR versus TEXT. It also speaks to the performance issue:

    • VARCHAR(n) Considered Harmful
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.