I’m checking all the queries that I run and this is what I see as suggested missed index (for example)
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[MBLPosition] ([DeviceKey])
INCLUDE ([PositionKey])
GO
Tables DDL look like so(not full)
CREATE TABLE [dbo].[MBLPosition](
[PositionKey] [int] IDENTITY(1,1) NOT NULL,
[PositionGKey] [uniqueidentifier] NOT NULL,
[DeviceKey] [int] NOT NULL,
CONSTRAINT [PK_MBLPosition] PRIMARY KEY CLUSTERED ([PositionKey] ASC)
ALTER TABLE [dbo].[MBLPosition] WITH CHECK ADD CONSTRAINT [FK_MBLPosition_MBLDevice_DeviceKey] FOREIGN KEY([DeviceKey])
REFERENCES [dbo].[MBLDevice] ([DeviceKey])
GO
ALTER TABLE [dbo].[MBLPosition] CHECK CONSTRAINT [FK_MBLPosition_MBLDevice_DeviceKey]
GO
I thought that all FK’s already indexes. No? And what does it mean INCLUDE ([PositionKey])
?
This question is indeed the key to the answer. You can add columns to your index to improve performance:
If you run a lot of queries that look like this
your query wouldn’t need to touch the table at all – it will be a quick index lookup.