SELECT 
  c.company_id 
FROM 
  cscart_products_categories pc 
  LEFT JOIN cscart_categories c ON c.category_id = pc.category_id 
WHERE 
  pc.product_id = 297 
GROUP BY 
  c.company_id 
LIMIT 
  2

Query time 0.00051

JSON explain

{
  "query_block": {
    "select_id": 1,
    "filesort": {
      "temporary_table": {
        "function": "buffer",
        "table": {
          "table_name": "pc",
          "access_type": "ref",
          "possible_keys": ["pt"],
          "key": "pt",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "ref": ["const"],
          "rows": 1,
          "filtered": 100
        },
        "table": {
          "table_name": "c",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "p_category_id"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["category_id"],
          "ref": ["egkcysbp_cscartn.pc.category_id"],
          "rows": 1,
          "filtered": 100
        }
      }
    }
  }
}

Result

company_id
1