I am adding two fields, facilityCode and facilitySubCode, to an existing table.
ALTER TABLE SampleTable ADD facilityCode int not null
ALTER TABLE SampleTable ADD facilitySubCode int null
The application will search for records from this table using either facilityCode or facilitySubCode but not both. I want to add an index to help with this query, but I'm not sure whether to create:
1) A single index with both columns. If so, which column to list first?
2) 2 indices, each consisting of 1 column.
As info, a facilityCode can have 0 to many sub codes, and a subcode has just 1 facility code. As far as usage statistics, I do not know which search will be more popular, searching by facility or searching by sub code. We can assume that MOST records will have both a facilityCode and a facilitySubCode.
Which option should I choose and why?