I have a table containing language translations. It has 30 columns for 30 languages.
My requirement is to search from all columns for a particular word (say “hello”).
I dynamically create Select statement:
Select * from Languages
where {English = “hello”
OR French = “hello”
OR German = “hello”}
Statement inside {} is generated dynamically.
If I have to index such a table, how do I do that?
Will I have to create one index for all 30 columns or create seperate 30 indexes for each column?
Please suggest better option.
You shouldn’t have 30 columns, you should use a table with a column for language name, and a column for the word, and an id to associate the 30 rows together. Then you can simply query for
WORD = 'hello'.If you absolutely must keep 30 columns, you will need to create 30 indexes, and the performance of the query will be 30 times slower than it needs to be.