i'm stuck with a performance of a simple sql query.
Query:
SELECT * FROM company
WHERE
(IDCompanyMain in (ID1, ID2...) or IDCompany in (ID1, ID2...))
and Network="XXX";
There are indexes on each field and ca 10M rows. Each query has 1 to 100 ids.
Each query needs >4 seconds! if i remove one of the conditions, results are ready in miliseconds.
EXPLAIN says, mysql uses network index and has ca 5M rows in question. If try to force certain index(USE or FORCE), no index is used.
What i am doing wrong?
EXPLAIN:
id, select_type, table, type, possible_keys, key, key_len, ref, rows, Extra
'1', 'SIMPLE', 'company', 'ref', 'PRIMARY,UNetwork_ID,IIDCompanyMain,INetwork', 'INetwork', '98', 'const', '5270286', 'Using where'