SELECT 
  id_path 
FROM 
  categories c 
  JOIN category_vendor_product_count p USING(category_id) 
WHERE 
  p.company_id = 4401

Query time 0.00060

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "15.59"
    },
    "nested_loop": [
      {
        "table": {
          "table_name": "p",
          "access_type": "ref",
          "possible_keys": [
            "PRIMARY"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "company_id"
          ],
          "key_length": "4",
          "ref": [
            "const"
          ],
          "rows_examined_per_scan": 33,
          "rows_produced_per_join": 33,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.74",
            "eval_cost": "3.30",
            "prefix_cost": "4.04",
            "data_read_per_join": "528"
          },
          "used_columns": [
            "company_id",
            "category_id"
          ]
        }
      },
      {
        "table": {
          "table_name": "c",
          "access_type": "eq_ref",
          "possible_keys": [
            "PRIMARY",
            "p_category_id"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "category_id"
          ],
          "key_length": "3",
          "ref": [
            "goimagine.p.category_id"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 33,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "8.25",
            "eval_cost": "3.30",
            "prefix_cost": "15.59",
            "data_read_per_join": "86K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
2
4
2/17
5/26
4/45
78
4/100
109
109/115
109/118
2/17/147
2/17/148
4/45/184
4/46/195
4/46/200
4/46/208
4/47/220
2566
8/6534
4/45/6634
4/6639
71/6727/6731
8/42/6767
8/6534/6771
10069
10070
10071
10072
10073/10074
10184
10184/10185
10184/10187
10184/10188