Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

Missing index

$
0
0

Hi Experts

I am confused  with the missing index suggestion by sql server. please see the table script bellow

CREATE TABLE [dbo].[tblNotifications](
	[NotificationID] [uniqueidentifier] NOT NULL,
	[ApplicationID] [varchar](255) NOT NULL,
	[NotificationTypeID] [int] NOT NULL,
	[DateOfNotification] [datetime] NOT NULL,
	[NotificationMessage] [varchar](max) NOT NULL,
	[Processed] [bit] NOT NULL,
	[ProcessedDate] [datetime] NULL,
	[id] [int] IDENTITY(1,1) NOT NULL,
 CONSTRAINT [PK_tblNotifications] PRIMARY KEY NONCLUSTERED 
(
	[NotificationID] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]



CREATE UNIQUE CLUSTERED INDEX [IX_tblNotifications] ON [dbo].[tblNotifications]
(
	[id] ASC
) ON [PRIMARY]

CREATE NONCLUSTERED INDEX [_dta_index_tblNotifications_27_738101670__K4_K7_1_2_3_5_9987] ON [dbo].[tblNotifications]
(
	[DateOfNotification] ASC,
	[ProcessedDate] ASC
)
INCLUDE ( 	[NotificationID],
	[ApplicationID],
	[NotificationTypeID],
	[NotificationMessage])  ON [PRIMARY]

CREATE NONCLUSTERED INDEX [ix_tblNotifications_ProcessedDate] ON [dbo].[tblNotifications]
(
	[ProcessedDate] ASC
) ON [PRIMARY]




ALTER TABLE [dbo].[tblNotifications] ADD  CONSTRAINT [DF_tblNotifications_ApplicationID]  DEFAULT ((-1)) FOR [ApplicationID]

ALTER TABLE [dbo].[tblNotifications] ADD  CONSTRAINT [DF_tblNotifications_NotificationTypeID]  DEFAULT ((-1)) FOR [NotificationTypeID]

ALTER TABLE [dbo].[tblNotifications] ADD  CONSTRAINT [DF_tblNotifications_NotificationMessage]  DEFAULT ((-1)) FOR [NotificationMessage]

ALTER TABLE [dbo].[tblNotifications] ADD  CONSTRAINT [DF_tblNotifications_Processed]  DEFAULT ((0)) FOR [Processed]

ALTER TABLE [dbo].[tblNotifications]  WITH CHECK ADD  CONSTRAINT [FK_tblNotifications_tblApplicationIds] FOREIGN KEY([ApplicationID])
REFERENCES [dbo].[tblApplicationIds] ([ApplicationID])

ALTER TABLE [dbo].[tblNotifications] CHECK CONSTRAINT [FK_tblNotifications_tblApplicationIds]

ALTER TABLE [dbo].[tblNotifications]  WITH CHECK ADD  CONSTRAINT [FK_tblNotifications_tblNotificationTypes] FOREIGN KEY([NotificationTypeID])
REFERENCES [dbo].[tblNotificationTypes] ([NotificationTypeID])

ALTER TABLE [dbo].[tblNotifications] CHECK CONSTRAINT [FK_tblNotifications_tblNotificationTypes]

Execution plan

SQL is asking to create an index on processedDate column, which already has an index on the column. Another thing I am noticing is the difference between actual and estimated row count.  i have  executed updated  stats with fullscan option on all those table still seeing any difference. 

any idea..

regards

VVT


Please mark answered if I've answered your question and vote for it as helpful to help other user's find a solution quicker


Viewing all articles
Browse latest Browse all 15889

Trending Articles