Your question is missing the solid part of the input data. What keys, where they are "is" how much is the sample why the INNER JOIN? and so on.
The keys (indexes) You have to stand on those fields involved in the condition of the sample, as in filtration. In your specific case is:
ON t1.`firma` = t2.`firma` AND t1.`product` = t2.`product`
that is, the keys (indexes) must be installed on the fields of company
, however, if You want to achieve maximum speed when such operations - in addition to being on the sidelines of the company
must be marked with the index type is KEY
- it is highly desirable that if they were numbers, because with numbers machines work much faster.
In General, all objects that You here in this way trying to "glue" with each other should be a unique identifier, ID, GUID, or some other (your choice).
*Actual numbers depends on the situation of course, in some cases this can be for example GUID's, it is desirable that it was NOT the name of the firm, a La "OOO Horns and hoofs" and product names like "a Loaf of sliced #1".
Well, if You very well want to use the names (titles) instead uniquely identify each object, keep in mind that the fall in the index the first 255 characters. And index on text fields (CHAR/VARCHAR) and in itself will take more than its numeric counterpart, and as a result will run slower than if it were a number (object ID).