
Returns Different Costs for the Same Missing Index Group in XML Showplans
Missing index groups can appear multiple times in XML Showplans with a different cost reported each time the missing index group appears. This can occur when different parts of a single query benefit differently from the same missing index group.
Consider the following example query:
SELECT i.CustomerID, c.ModifiedDate, City
FROM NewIndividual i JOIN NewCustomer c ON i.CustomerID = c.CustomerID
AND c.CustomerType = 'I'
JOIN NewCustomerAddress ca ON ca.CustomerID = c.CustomerID
JOIN NewAddress a ON a.AddressID = ca.AddressID
WHERE i.CustomerID = 16701
In this query, the two different join conditions on the CustomerID column might produce two identical missing index groups that contain the same index on the NewIndividual.CustomerID column. In this case, the sys.dm_db_missing_index_groups dynamic management view would have only one row for the missing index group. However, the missing index group would appear multiple times in the XML Showplan output, with different costs for the different join conditions.