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.