CREATE TABLE [dbo].[session](
[id] [int] IDENTITY(1,1) NOT NULL,
[user_id] [int] NOT NULL,
[session_id] [uniqueidentifier] NOT NULL,
[supervisor_id] [int] NULL,
some columns ..
CONSTRAINT [PK_session] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
CREATE TABLE [dbo].[tbl2](
[id] [int] IDENTITY(1,1) NOT NULL,
[close_date] [datetime] NULL,
[edit_date] [datetime] NULL,
[session_id] [uniqueidentifier] NOT NULL,
some columns ..
CONSTRAINT [PK_tbl2] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
Have two tables which I join wtih sesssion_id , on each table is more than 20 000 values and join is too slow. Is good idea to create nonclustered index on session_id
columns which is uniqueidentifier
type ? Or there is another way to do the join faster ?
Edit: For example query is like :
SELECT some_columns...
FROM [dbo].[session] s
INNER JOIN [dbo].[tbl2] t2 on s.[session_id] = t2.[session_id]
WHERE t2.some_column = something
Aucun commentaire:
Enregistrer un commentaire