r/SQLServer • u/cute_polarbear • Jan 18 '26
Question Sql hashjoin against large table
Hi,
I have a temp table indexes on int Id, joining to a large table (1billion+) rows indexed on int id, both unique, 1 to 1. Temp table can be few hundred rows to hundred of thousand rows. Does it make sense to do a hashjoin in this scenario or normal inner join? Thank you.
5
Upvotes
View all comments
Show parent comment
1
u/cute_polarbear Jan 18 '26
yeah. so #temp contains indexed CertainUniqueId column, it's a smaller subset of the real table A, which also has an indexed CertainUniqueId column. #temp might be 200 to 500k rows. table A continues to grow at 1B+ rows. SP doing this gets called every few seconds and often concurrently (with updates frequently in other processes). I think my post is more to also understand Hash join more, specially what I see as the "Probe" phase of the larger table A, to Hash and match to (the smaller) #temp. Wouldn't that "Probe" phase be super long in most cases (even 1-1) if table A is 1B+ rows in my case (even disregarding temp db spill over potentials)?