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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:03:58+00:00 2026-05-11T20:03:58+00:00

I have a table like this: create table SomeTable ( tableKey int identity(1,1) not

  • 0

I have a table like this:

create table SomeTable (
   tableKey    int identity(1,1) not null
,  foreignKey  int               not null
,  longDesc    nvarchar(max)     not null
,  shortName   varchar(100)      null
)

I need to use shortName in a where clause:

select 
    tableKey 
from 
    SomeTable 
where 
    foreignKey = @foreignKey 
and shortName = @shortName

and that needs to be fast – this table has millions of rows. Can I move it above the longDesc column and see a speed increase? I assume that the database can simply jump to the correct byte offset as long as the columns are constant sized. Jumping past a varchar column must incur some kind of performance penalty, yes?

Alternatively, what if I made longDesc nchar(3784)? (Which should make each row fill an 8KB page) Would that increase speed?

I see one of the answers here alludes to the fact that order matters in terms of used space, but I’m not sure how that translates to performance.

  • 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-11T20:03:58+00:00Added an answer on May 11, 2026 at 8:03 pm

    For the greatest speed, you would create a persisted computed column like shortNameCrc = checksum(shortName), then create an index on (foreignKey, checksum(shortName)) and include (shortName). Then you would query like
    where foreignKey = foreignKey
    and shortNameCrc = checksum(@shortName)
    and shortName = shortName

    If SomeTable is not clustered on tableKey then you would want to add tableKey as an include columns. If it is clustered on tableKey then the value is already present in the covering index.

    Filling a page should not cause a speed increase, this will cost you in excess memory usage and a greater likelihood in having to visit disk. Filling a page may be better for throughput in some cases for a workload that is very high in contention in the same physical area.

    Making shortName char(100) may be better than varchar(100). Given unlimited ram I suspect it would be. In the real world it may depend on the average length and the likelihood of a cache miss.

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

Sidebar

Ask A Question

Stats

  • Questions 135k
  • Answers 135k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer So a .wav file has a few standard chunks. …… May 12, 2026 at 7:03 am
  • Editorial Team
    Editorial Team added an answer The first thing I'd do to run this down is… May 12, 2026 at 7:03 am
  • Editorial Team
    Editorial Team added an answer It depends. Are you using SSRS 2005 or 2008? For… May 12, 2026 at 7:03 am

Related Questions

I can't really think of the best way to phrase this question, so I'll
How do you get a list of all the tables and use that list
I have a report that calculates multiple date differences (in business days, not DATEDIFF)
I created a batch file to run SqlMetal and generate Linq2Sql data classes, check

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.