Open GoogleCodeExporter opened 9 years ago
Updated diff. The previous one only changes NVARCHAR(N) to NVARCHAR(MAX); this
one also does the same to VARCHAR.
Original comment by sok...@gmail.com
on 4 Jun 2012 at 9:37
Attachments:
Hmm.. forget about it. I have a composite index on a VARCHAR(50) column and an
INT column, e.g.
CREATE INDEX ix_test_lookup ON test (varchar_col, int_col)
With bind parameter being VARCHAR(MAX), e.g.
exec sp_executesql N'SELECT * FROM test WHERE varchar_col = @P1 AND int_col = @P2',
N'@P1 varchar(MAX),@P2 int',
'abc',123
SQL Server is not able to use the index as intended, as it will resort to very
inefficient seek predicates:
Start: test.varchar_col > Scalar Operator(ExprXXX), End: test.varchar_col < Scalar Operator(ExprYYY)
With bind parameter being VARCHAR(N) where N is anything from 1 to 8000, e.g.
exec sp_executesql N'SELECT * FROM test WHERE varchar_col = @P1 AND int_col = @P2',
N'@P1 varchar(8000),@P2 int',
'abc',123
SQL Server will use the index as intended, with seek predicates:
Prefix: test.varchar_col, test.int_col = Scalar Operator(@P1), Scalar Operator(@P2)
This is truly bizarre since VARCHAR(MAX) should be the same as VARCHAR(8000).
Original comment by sok...@gmail.com
on 4 Jun 2012 at 11:39
My understanding was wrong, VARCHAR(MAX) is a different beast than
VARCHAR(8000).
Original comment by sok...@gmail.com
on 4 Jun 2012 at 11:50
Improved diff to use varchar_maxlength and wvarchar_maxlength as ColumnSize
when appropriate
Original comment by sok...@gmail.com
on 5 Jun 2012 at 12:44
Attachments:
I don't think I can use the patch as-is - the column lengths are typically used
to indicate the data size and I don't want to lose that.
Please reopen if I'm misunderstanding something.
Original comment by mkleehammer
on 29 Sep 2012 at 7:54
I thought `info.StrLen_or_Ind` is to indicate the data size?
`info.ParameterType` and `info.ColumnSize` combine to indicate the bind
parameter type.
Original comment by sok...@gmail.com
on 30 Sep 2012 at 12:13
You are correct. I was dealing with another Issue and made the same mistake.
I'll look at this again. Thanks
Original comment by mkleehammer
on 30 Sep 2012 at 12:49
Original issue reported on code.google.com by
sok...@gmail.com
on 4 Jun 2012 at 6:46Attachments: