How to create an index in this temporary table?

I am trying to speed up the query, and I think I am confused about the indexes. How and which index I would add to this table. The identifier is unique, will it be the main index?

CREATE TABLE #OSP ( [Id] UniqueIdentifier, [YearMonth] int, [Expenditure] decimal (7,2), [Permit] decimal (7,2) ); 
+4
source share
2 answers

If you join id then creating an index will help.

I think this will work:

 CREATE TABLE #OSP ( [Id] UniqueIdentifier, [YearMonth] int, [Expenditure] decimal (7,2), [Permit] decimal (7,2) ); CREATE UNIQUE CLUSTERED INDEX [idx_id] ON #Osp ([Id] ASC) 
+1
source

You can specify the primary key in the create table .

 CREATE TABLE #OSP ( [Id] UniqueIdentifier primary key, [YearMonth] int, [Expenditure] decimal (7,2), [Permit] decimal (7,2) ); 
+3
source

All Articles