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

  • Home
  • SEARCH
  • 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 7178617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:57:26+00:00 2026-05-28T16:57:26+00:00

Possible Duplicate: is there an advantage to varchar(500) over varchar(8000)? In SQL Server we

  • 0

Possible Duplicate:
is there an advantage to varchar(500) over varchar(8000)?

In SQL Server we can specify the field type varchar(n):

Storage size is the actual length in bytes of the data entered, not n
bytes.

Often when planning a database structure I try to imagine the maximum possible length of strings which are to be stored in these varchar fields and then set that imagined size + some backup for the varchar field. Sometimes it may occur that the initially provided room is not enough for the field and then I need to increase the length.

But actually, is it worth limiting the varchar field to some value and not just set something like varchar(5000) or even varchar(max) which will 100% suit the case? Is there any advantage maybe in page organization in SQL Server or index organization when I limit that n length?

Update

Here is what I mean (the advantage): https://stackoverflow.com/a/5353196/355264

Yes, the query optimizer can guess how many rows fit in a page, if you
have a lot of varchar fields that are larger than necessary, SQL
Server can internally guess the wrong number of rows.

Is the above true? And are there any other advantages?

  • 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-28T16:57:26+00:00Added an answer on May 28, 2026 at 4:57 pm

    For one thing – you CANNOT index any column that’s over 900 bytes in size.

    That alone (to me) is a killer criteria against using varchar(5000) (or varchar(max)) all the time, even if not needed….

    Use the appropriate size.

    Also: varchar adds at least 2 bytes of overhead, so for strings of 10 characters or less, I would always recommend using char(n) instead.

    char(5) will use 5 bytes of storage – always. varchar(5) uses between 2 and 7 bytes of storage.

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

Sidebar

Related Questions

Possible Duplicate: Is there a Max function in SQL Server that takes two values
Possible Duplicate: Is there a tool that can display a SVN repository visually (
Possible Duplicate: C++ char* vs std::string Is there any advantage to using char*'s instead
Possible Duplicate: Is there SQL parameter binding for arrays? I was wondering if there
Possible Duplicate: Is there a good reason to use upper case for T-SQL keywords?
Possible Duplicate: Benefits of Initialization lists I was wondering if there was an advantage
Possible Duplicate: Are there disadvantages to using a generic varchar(255) for all text-based fields?
Possible Duplicate: Is there a way to embed a browser in Java? How can
Possible Duplicate: Is there a php library for email address validation? Hi there, I
Possible Duplicate: Is there any way to determine text direction from CultureInfo in asp.net?

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.