Solved

Can I consolidate missing indexes recommendations from SQL 2008

Posted on 2011-03-17
2
427 Views
Last Modified: 2012-05-11
I'm getting some timeout errors and SQL Server suggested several missing indexes. Here's the table definiton for the columns mentioned in the missing indexes. I've left off all other columns (a few dozen).
CREATE TABLE [dbo].[MyTable](
	[RowID] [int] IDENTITY(1,1) NOT NULL,
	[Deleted] [bit] NOT NULL,
	[Requested] [datetime] NULL,
	[Received] [datetime] NULL,
	[OtherID] [int] NULL,
	[UserID] [int] NULL,
 CONSTRAINT [PK_MyTable] PRIMARY KEY CLUSTERED 
(
	[RowID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[MyTable] ADD  CONSTRAINT [DF_MyTable_Deleted]  DEFAULT ((0)) FOR [Deleted]
GO

Open in new window

SQL 2008 suggested the following missing indexes which overlap somewhat. The first one is probably for the query with the biggest impact.

-- Suggested MyTable Missing Indexes:
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[MyTable] ([Deleted],[Requested])
INCLUDE ([RowID],[OtherID],[UserID],[Received])
GO

CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[MyTable] ([Deleted],[Requested])
INCLUDE ([RowID],[OtherID],[UserID])
GO

CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[MyTable] ([OtherID])
GO

CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[MyTable] ([OtherID],[Deleted])
GO

Open in new window


Which of the suggested indexes are redundant or which ones can I combine (and if so, how)?

Thanks in advance.
0
Comment
Question by:ZekeLA
2 Comments
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 500 total points
ID: 35160472
on the face of it these 2 indexes would probably suffice

to cover all the range of instances encountered...

however i'm not clear on how useful the deleted column will be indexed
since its a bit column and they don't (only 3 possible values null 0,1) make good
index sources...

is deleted only 1 for a very small proportion of the rows? (in which case it may become useful in some circumstances...) but probably shouldn't be included in the last index...
-- Suggested MyTable Missing Indexes:
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[MyTable] ([Deleted],[Requested])
INCLUDE ([RowID],[OtherID],[UserID],[Received])
GO


CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[MyTable] ([OtherID],[Deleted])
GO

Open in new window

0
 
LVL 1

Author Comment

by:ZekeLA
ID: 35160847
Yes, Deleted is only used for a small number of samples. I tried out the first index and only gained about 10% or so. I suspect missing indexes is not the approach to this problem. I think I'll need to restructure some views since there's too much logic occurring on the fly.

But you get the points anyway. Thanks.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question