MySQL table T holds report rows for fewer than 10 companies. A view finds the latest date for each company, and another joins those company and date pairs back to T to get all rows from the latest reports.
The join is slow, but a query with the same pairs written as OR conditions is much faster. T has separate indexes and a composite index on company_id and date. What should I check?
c.58+windup_19:
Also check the column order in the indexes. A primary key that contains both columns isn't necessarily useful for a lookup on both if other columns come between them.