r/SQLOptimization • • Dec 18 '23
Merge join questions
I have a stored procedure that creates two temp tables. Both temp tables have a primary key setup with a nvarchar(10) and a date field. Most of the other fields are numeric and not indexed. One table gets loaded with about 330k of rows and the other gets about 455k. Sql server 2019 will not use a merge join on the query that links these two tables together by only the two indexed fields. It displays and adaptive join but always picks a hash match. Sql server adds a "parallelism (repartition streams)" to the plan. Any suggestions on how I can make it perform the merge join with out the forcing it in the query?
View all comments
Show parent comment
2
u/Alkemist101 Dec 29 '23
They are part of the alter which is an additional step. I mean as part of the create table so all done in one step. Why nvarcher and not varchar?