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

Query time 0.00083

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "40.73"
    },
    "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": 89,
          "rows_produced_per_join": 89,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.68",
            "eval_cost": "8.90",
            "prefix_cost": "9.58",
            "data_read_per_join": "1K"
          },
          "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": 89,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "22.25",
            "eval_cost": "8.90",
            "prefix_cost": "40.73",
            "data_read_per_join": "232K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
2
2/17
2/17/147
2/17/148
2/17/149
13995
13995/13996
13995/13997
13995/13998
13995/13996/13999
13995/13997/14000
13995/13996/14001
13995/13996/14002
13995/13997/14003
13995/13997/14004
13995/13997/14005
13995/13996/14006
13995/13998/14007
13995/13996/14008
13995/13997/14009
13995/13996/14010
13995/13997/14011
14012
14012/14013
14012/14014
14012/14015
14016
14016/14017
14016/14018
14019
14020
14849/14021
14019/14022
14019/14023
14019/14024
14019/14025
14019/14026
14019/14027
14019/14028
14019/14029
14849/14040
14020/14041
14019/14042
14849/14043
14849/14206
14849/14207
14849/14208
14849/14209
14849/14210
14849/14211
14849/14212
14849/14213
14020/14214
14849/14215
14849/14831
14019/14832
14849/14833
14019/14834
14019/14835
14019/14836
14019/14837
14019/14838
14019/14839
14019/14840
14019/14841
14019/14842
14019/14843
14019/14845
14849
14849/15095
14019/15096
13995/13998/15098
14016/15099
14019/15100
13995/13998/15101
14012/15103
14019/15104
14019/15105
14019/15106
13995/13997/15107
14849/15108
14019/15109
14019/15110
14019/15111
14019/15112
14849/15113
13995/13996/15114
13995/13997/15115
15345