[dba-SQLServer] How to construct queries

jwcolby jwcolby at colbyconsulting.com
Fri Dec 11 12:28:41 CST 2009


I often have to do things like "supply counts of records where..." and the list will be something like:

FieldA = "Y" or FieldB = "Y" or FieldC = "Y" ...

Often times the counts must be for sets of fields, for example FieldA through FieldG or FieldX 
through FieldZ

These fields are usually a small minority of the total 50 million records, sometimes a million, 
sometimes 5 million etc.

So I have routinely created cover indexes for the groups, one index for FieldA..FieldG, another 
index for FieldX .. FieldZ.

If a query requests data from fields in both groups, will the query use both cover indexes to grab 
the data for the records?

Is there a more efficient way to do these kinds of counts?

-- 
John W. Colby
www.ColbyConsulting.com



More information about the dba-SQLServer mailing list