I need to optimize a table (It's INNODB) where I'm going to do a query using IN in two columns.
This is the query:
SELECT `emails`.* FROM `emails`
WHERE (`from` IN ('[email protected]', '[email protected]') OR `to` IN ('[email protected]', '[email protected]'))
the from and to fields are VARCHAR(255)
How I can create an index to help speed it up. Or if I should change my query strategy please let me know
I'm not sure if I should create one index for each column, or a single index with the two columns. I'm also not sure if the IN clause will make the index work or not.