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

Query time 0.00078

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "30.48"
    },
    "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": 66,
          "rows_produced_per_join": 66,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.78",
            "eval_cost": "6.60",
            "prefix_cost": "7.38",
            "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": 66,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "16.50",
            "eval_cost": "6.60",
            "prefix_cost": "30.48",
            "data_read_per_join": "172K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
2
4
2/13
2/15
2/17
2/19
5/27
23/33
4/48
4/51
2/82
3/87
71/91/90
109
109/110
109/114
109/116
109/117
109/118
2/13/131
2/13/132
2/13/133
2/13/134
2/13/137
2/17/147
2/17/149
2/19/157
2/19/161
2/18/170
4/51/250
1164
1165
1168
1170
1164/1171
1164/1172
1164/1173
1164/1174
1164/1175
1164/1176
1177
1178
1165/1179
1165/1180
1165/1181
1177/1182
1177/1183
1178/1188
1178/1189
1197
1200
1170/1265
1170/1266
1170/1267
1170/1268
1165/1272
1165/1273
1170/1285
1165/1287
1302
4/46/195/22740/7651
2/17/11913
1177/12367