• This article has been a great learning experience for me, as have all the others. But I do have a question about the Histogram - why does it only take the first column of the index into account? I ask because I have a table with approx 62 million rows with 2 main, multi-column, non-clustered, indexes on them. But both have the same first column. From what I've read in this article, the histograms for both would identical, right?

    To give a bit of background the current first column of both indexes (campaignid) has about 1000 distinct values which aren't exactly evenly distributed, I'd say 40% of the distinct values take up about 80% of the rows. The next columns in index A is a datetime field (that has & needs time defined - so it would be almost unique) and the other is a varchar(50) that on it's own has 2000+ distinct values, but is also uneven in its distribution.

    I'm trying to work out if switching the order of the columns in both indexes would be of benefit to SQL Server. Most queries on this table have a clear preference of using one index or the other, because the where clause would only have those 2 indexed fields in it, but I have seen on some occasions the query planner decide that a table scan would be of more benefit.

    Any insight you could offer would be much appreciated,

    Drew