Question

Im running a query that is taking 2 seconds but it should perform better, so I run the Execute Plan details from SQL Managemenet Studio and I found a "step" in the process that the Cost is 70%.

enter image description here

Then, I right click on the item and I found an option that says "Missing Index Details", after I clicked that then a query with a recommendation is generated:

/*
Missing Index Details from SQLQuery15.sql - (local).application_prod (appprod (58))
The Query Processor estimates that implementing the following index could improve the query cost by 68.8518%.
*/

/*
USE [application_prod]
GO
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[cloud_document] ([isactivedocument])
INCLUDE ([objectuid])
GO
*/

So my question is exactly what happens if I execute the query? Is it going to affect my database, is there any sideback or sideeffects after applying that?

Thanks a lot and appreciate in advance.

Was it helpful?

Solution 2

The literal meaning is telling you to build an index on isactivedocument of table [dbo].[cloud_document], from which I assume you are using isactivedocument as a condition to filter the table, and select the column objectuid. Something like

select objectuid, ... from [dbo].[cloud_document] where isactivedocument = 0/1

Note that the "Clustered Index Scan (70%)" doesn't mean it's a problem of the clustered index. It means you don't have index on isactivedocument, then sql engine has to scan clustered index to find what you want. That's why it's taking so much pressure. Once you create index on isactivedocument, check out the plan again, and you'll see the node becomes "index seek", which is a much faster way to find out what you want.

Usually if your database stress mainly comes from query, new index doesn't do much harm to your system. Just go ahead and create the index. But of course you need to keep index quantities as less as possible.

OTHER TIPS

Running the query qill create an Index on the table specified (cloud_document).

This should improve the reading performance and improve performance/query time.

It does also affect the performance of INSERT/UPDATE/DELETE statements as the indexes needs to be maintained during these statements.

The decision to use indexing, how many indexes and what the index consists of is more an art than an exact science.

The actual maintinance of indexes, defragmenting, and statistics is something that can be automated, but should be left, until you have a better understanding of what indexes are and what they do.

I would recomend that you start reading some documentation regarding indexing.

May start with Stairway to SQL Server Indexes

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top