Solved

Can I consolidate missing indexes recommendations from SQL 2008

Posted on 2011-03-17
2
424 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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now