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

Query time 0.00427

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "63.41"
    },
    "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": 139,
          "rows_produced_per_join": 139,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.86",
            "eval_cost": "13.90",
            "prefix_cost": "14.76",
            "data_read_per_join": "2K"
          },
          "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": 139,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "34.75",
            "eval_cost": "13.90",
            "prefix_cost": "63.41",
            "data_read_per_join": "363K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
2
4
5
8
2/15
2/17
2/18
23
5/25
5/26
4/45
4/46
4/47
4/48
4/51
4/52
71
71/73
4/76
78
2/81
2/82
3/87
71/91/90
5/98
4/100
78/106
109
109/112
109/118
2/13/131
2/13/132
2/17/147
2/15/169
2/18/170
4/179
4/45/186
4/45/187
4/45/191
4/45/194
4/46/195
4/46/195/196
4/46/197
4/46/199
4/46/205
4/179/257
4/179/260
4/179/266
4/99/271
4/99/272
4/76/278
12/55/305
12/59/317
12/319
2/326
5/2185
2566
5843
7710/6247
7710/6358
5843/6365
6366
5843/6368
5843/6369
6370
7710/6483
4/51/6667
5/26/6692
5/97/6726
8/40/6738
8/40/6739
6817
6366/6866
8498/6903
7221
6366/7265
7266
7405
4/46/195/22740/7651
7695
7221/7712
7221/7713
7221/7714
7266/7905
7266/8031
8498/8443
6366/8488
6366/8489
8498
6370/8499
7405/8694
7405/8695
9148
7266/9321
6370/8499/10161
10163
5843/10333
7405/10334
7405/10335
7405/10336
9148/10409
6370/10482
7266/10812
10853
11350
13321
13321/13356
13321/13357
13321/13358
13321/13359
13579
13321/13628
14094
15094
15466
9148/16173
9148/18857
9148/18877/18878
9148/18877/18879
9148/18877/18880
9148/18877/18881
9148/18886
11350/19509
11350/19514
19515
19515/19803
7266/20143
10163/20302
7266/20611
7266/20955