?
Solved

Can I consolidate missing indexes recommendations from SQL 2008

Posted on 2011-03-17
2
Medium Priority
?
430 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

777 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