Pasting thousands of IDs into an IN list works, until it does not. See where the time goes and how to keep the answer the same with a temp table.
Resumable ADD CONSTRAINT in SQL Server 2022: Pausing a Primary Key Build
Use resumable ADD CONSTRAINT in SQL Server 2022 to pause a key build, inspect progress, resume safely, and understand abort behavior.
Modeling Data Before Writing Tables
Modeling data before tables clarifies entities, relationships, keys, and grain so schema changes do not discover the rules too late.




