Where Are the Indexes?

INSPYR Global Solutions, Technical Blog

Where are the Indexes

At INSPYR Global Solutions (IGS), building scalable and high-performing solutions goes beyond writing functional code; it requires a deep understanding of how systems behave under real conditions. Database performance is a critical part of that equation, and small optimizations can make a significant difference at scale. 

Topics like index management are a great example of the type of practical, detail-oriented knowledge that strengthens engineering judgment. For professionals looking to grow, developing the ability to identify, evaluate, and prioritize these optimizations is key to delivering efficient and reliable solutions. 

Let’s explore how to detect and manage missing indexes, highlighting the importance of going beyond assumptions and making data-driven decisions to improve performance. 

Sometimes we assume that the indexes created during the design phase are sufficient— and why not? We have experience. However, we can still overlook some additional steps, perhaps assuming that it is something the application layer should fix. Sometimes that is true, sometimes it is not. A comprehensive solution may be the best approach; ultimately, the decision is yours.  

Missing indexes in SQL Server are optimization opportunities identified by the database engine that can improve query performance. They are detected through Dynamic Management Views (DMVs) (sys.dm_db_missing_index_details, groups, columns) that analyze execution plans. Although useful, they should not be applied blindly; they require cost-benefit evaluation and proper testing.  

Steps to Identify and Manage Missing Indexes

Identification (DMVs): Use queries against sys.dm_db_missing_index_details to find recommendations, ordered by the estimated impact (avg_estimated_impact).  

Execution Plan Analysis: SQL Server Management Studio (SSMS) displays index suggestions in green at the top of the graphical execution plan.  

Evaluation: Before creating an index, verify whether a similar one already exists to avoid duplication (duplicate or “twin” indexes), which unnecessarily consumes resources.  

Creation and Testing: The generated scripts should be tested in development environments first, not directly in production. Limit index creation to a maximum of 5–10 per table to avoid excessive overhead on write operations.  

How to View Missing Indexes

SQL Server stores this information in Dynamic Management Views (DMVs).  

The principal DMVs are: 

  • sys.dm_db_missing_index_details: Provides details about the table and the missing columns (equality, inequality, and included columns).   
  • sys.dm_db_missing_index_groups: Acts as a bridge between the details and the statistics.   
  • sys.dm_db_missing_index_group_stats: Shows the potential impact (how much the query would improve) and how many times that index has been needed.

Script to List the Indexes with the Highest Impact

(The code should always be tested first in development or QA before being executed in Production.) 

SELECT  

    migs.avg_user_impact * (migs.user_seeks + migs.user_scans) AS [Estimated Impact], 

    mid.statement AS [Table], mid.equality_columns AS [Equality Columns], 

    mid.inequality_columns AS [Unequality Columns], 

    mid.included_columns AS [Included Columns], 

    'CREATE INDEX [IX_' + OBJECT_NAME(mid.object_id)  

    + '' + REPLACE(REPLACE(REPLACE(ISNULL(mid.equality_columns,''),', ',''),'[',''),']','') + '] ON '  

    + mid.statement + ' (' + ISNULL(mid.equality_columns,'')  

    + ISNULL(CASE WHEN mid.equality_columns IS NOT NULL  

    AND mid.inequality_columns IS NOT NULL THEN ',' ELSE '' END,'')  

    + ISNULL(mid.inequality_columns,'') + ')'  

    + ISNULL(' INCLUDE (' + mid.included_columns + ')','') AS [Creation Script] 

FROM sys.dm_db_missing_index_groups mig 

INNER JOIN sys.dm_db_missing_index_group_stats migs ON migs.group_handle = mig.index_group_handle 

INNER JOIN sys.dm_db_missing_index_details mid ON mig.index_handle = mid.index_handle 

ORDER BY [Estimated Impact] DESC;

Key Considerations

Impact vs. Cost: A high avg_user_impact is positive, but make sure the index does not excessively slow down insert/update operations.  

Do not create everything blindly: SQL Server may suggest very similar or “twin” indexes. Analyze whether an existing index can be modified (for example, by adding INCLUDE columns) before creating a new one.  

Functions: The use of functions in the WHERE clause may prevent the optimizer from using indexes.  

Maintenance: Periodic rebuilds (REBUILD or REORGANIZE) are necessary to maintain efficiency at the table/page level.  

Persistence: The information in these views is cleared whenever the SQL Server service is restarted.  

Execution Plans: You can also see these suggestions directly in the Execution Plan of a query in SQL Server Management Studio (SSMS); they will appear in green text as Missing Index. 

At INSPYR Global Solutions, attention to detail in areas like database performance is part of what enables us to build efficient, scalable solutions that perform in real-world scenarios. 

For engineers, mastering these types of optimizations is a key step in career growth: moving from implementing solutions to refining them, understanding their impact, and continuously improving how systems perform over time. 

If you’re passionate about building high-performing, scalable systems and refining the details that make a difference, join our team today.

Victor-Manuel-Labastida-500x500

Victor Manuel Labastida Flórez

Victor Manuel Labastida Flórez is a Developer at INSPYR Global Solutions with over 15 years of experience specializing in SQL and .NET technologies. He has worked on projects across industries such as finance, automotive, and consulting, applying his expertise to complex business environments. Outside of work, he enjoys learning about new technologies and spending time with his family.

Contact Us

We’re here for you when you need us. How can we help you today?

Share This Article

Related News & Insights

Are we calling everything burnout

Are We Calling Everything Burnout? Keys to Prevent Burnout in Tech

Why are the solid principles for AI important

Why Are the Solid Principles for AI Important?

Why-documentation-skiils-acelerate-your-tech-career

Why Documentation Skills Accelerate Your Tech Career

How MCP Servers Are Shaping the Future of AI-Assisted Software Development

How MCP Servers Are Shaping the Future of AI-Assisted Software Development

Importance of a Discovery Phase

Measure Twice, Cut Once: The Importance of a Discovery Phase