SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2005
    Posts
    436
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    1 Table 1 Text, 1 Table 1 Text and 1 Varchar, or 2 Tables 1 Text 1 Varchar

    I have an input field where 95% of the time, the submission will be below 100 characters. The other 5%, it will be over 256 characters. What's the best way to store this data? It will always be one or the other, and I will either be looking at the small entries OR the big entries, never both at the same time.

    I'm thinking its best to have a Text column and a Varchar column in the same table.

    Would having an extra text column affect efficiency if it's empty and the query doesn't look at it? I could use scripting to look in a different table if it would be most efficient.

    It would be easiest on the scripting end if everything was in one column, would making 1 Text column really kill efficiency if all the data I'm looking through is small?

    Thanks,
    e39m5

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by e39m5 View Post
    Would having an extra text column affect efficiency if it's empty and the query doesn't look at it?
    no

    Quote Originally Posted by e39m5 View Post
    would making 1 Text column really kill efficiency if all the data I'm looking through is small?
    no





    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Depends on what database--SQL Server treats TEXT* far, far differently than VARCHAR.

    * you should not use TEXT anymore if you are using Sql 2005 or better. VARCHAR(MAX) is vastly superior in every way.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •