I have a large table (100000+ rows) in which are 4 columns of same conceptual value.
Say a record represents a competition between players whose names are in columns A, B, C and D.
And A + B plays vs C + D.
When I query that table for all competitions played by a guy named “DOE”, I need to inspect the 4 column values for the name:
… Where (Column A like ‘DOE%’ OR Column B like ‘DOE%’ OR Column C like ‘DOE%’ OR Column D like ‘DOE%’)
AND … Other conditions…
And since the table is huge, I need a way to index on all those 4 columns.
I know I can create a secondary table storing each player name together with his position A, B, C or D and the main table’s RowID, but I suspect there should be a better way…
Any clue from a SQLServer guru?
Just put an index on each column (4 indexes total).
That way the server can query each index and put together the results according to the conditions. This allows for a wide range of queries and is still reasonably fast.