SELECT 
  id_path 
FROM 
  cscart_categories c 
  JOIN cscart_category_vendor_product_count p USING(category_id) 
WHERE 
  p.company_id = 942

Query time 0.00037

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.00926796,
    "nested_loop": [
      {
        "table": {
          "table_name": "p",
          "access_type": "ref",
          "possible_keys": ["PRIMARY"],
          "key": "PRIMARY",
          "key_length": "4",
          "used_key_parts": ["company_id"],
          "ref": ["const"],
          "loops": 1,
          "rows": 4,
          "cost": 0.0024134,
          "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": ["u508912950_dev_2025.p.category_id"],
          "loops": 4,
          "rows": 1,
          "cost": 0.00685456,
          "filtered": 100
        }
      }
    ]
  }
}

Result

id_path
1629/1630/1631
1629/1630/1632
1629/1630/1633
1629/1630/1634