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 412529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:05:40+00:00 2026-05-12T18:05:40+00:00

Should I choose the smallest datatype possible, or if I am storing the value

  • 0

Should I choose the smallest datatype possible, or if I am storing the value 1 for example, it doesn’t matter what is the col datatype and the value will occupy the same memory size?

The question is also, cuz I will always have to convert it and play around in the application.


UPDATE

I think that varchar(1) and varchar(50) is the same memory size if value is “a”, I thought it’s the same with int and tinyint, according to the answers I understand it’s not, is it?

  • 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-12T18:05:40+00:00Added an answer on May 12, 2026 at 6:05 pm

    Always choose the smallest data type possible. SQL can’t guess what you want the maximum value to be, but it can optimize storage and performance once you tell it the data type.


    To answer your update:

    varchar does take up only as much space as you use and so you’re right when you say that the character “a” will take up 1 byte (in latin encoding) no matter how large a varchar field you choose. That is not the case with any other type of field in SQL.

    However, you will likely be sacrificing efficiency for space if you make everything a varchar field. If everything is a fixed-size field then SQL can do a simple constant-time multiplication to find your value (like an array). If you have varchar fields in there, then the only way to find out where you data is stored it to go through all the previous fields (like a linked list).

    If you’re beginning SQL then I advise just to stay away from varchar fields unless you expect to have fields that sometimes have very small amounts of text and sometimes very large amounts of text (like blog posts). It takes experience to know when to use variable length fields to the best effect and even I don’t know most of the time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What datatype should I choose for storing an IP Address in a SQL Server?
I am having trouble finding information related to which i should choose, OpenGL ES
can you just tell me for which type of requirement we should choose framework
When should I choose one over the other? Are there any pointers that you
Which audio codec should I choose for my C# software development project where the
Your task, should you choose to accept it, is to write a Perl regular
What is the difference between ListView and ArrayList and what should i choose when
I got the design (PSD) from client. Which should i choose to make custom
I've got a choose statement that should be setting my variable but for some
for site which language is chinese what should i choose @font-face or sIFR for

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.