Using SQL Server 2014:
In my TSQL database application, I create temporary tables that hold the primary key IDs of the records I am working with.
DECLARE @TempListOfIDs TABLE(PKID BIGINT)
- The table will hold between 1000-5000 items in it. That is the work chunk the stored procedure needs to get done on each execution. I throttle the workload with this approach.
- I use the temporary table to join it with quite large tables, all of them have clustered index based on the PKID. So joining is quite optimised at the larger table side, but not sure with the temp table side.
The question is should I create a clustered index on @TempListOfIDs.PKID column? I am concern that with such small number of rows in the table (<5000 rows) the cost of creating the clustered index on the temp table is more than its benefit.