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

Query time 0.00039

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.02882154,
    "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": 22,
          "cost": 0.00586706,
          "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": 22,
          "rows": 1,
          "cost": 0.02295448,
          "filtered": 100
        }
      }
    ]
  }
}

Result

id_path
309
317
317/319
317/319/471
317/325/484
317/325/485
241/644
902/985/1206
215/1614
1617
1629
1629/1630
1629/1630/1632
317/1655
317/1655/1656
1690
1716
1726
1727