SELECT 
  id_path 
FROM 
  q_categories c 
  JOIN q_category_vendor_product_count p USING(category_id) 
WHERE 
  p.company_id = 12

Query time 0.00105

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "186.49"
    },
    "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": 130,
          "rows_produced_per_join": 130,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "4.49",
            "eval_cost": "26.00",
            "prefix_cost": "30.49",
            "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": [
            "portal.p.category_id"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 130,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "130.00",
            "eval_cost": "26.00",
            "prefix_cost": "186.49",
            "data_read_per_join": "343K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
2
2/10
2/11
12/13/14
12/13/44
12/50/51/58
12/50/84
12/604/91
2/144/100
2/144/100/101
2/144/100/101/102
2/144/100/106
2/144/100/113
2/144/100/113/115
2/144/100/117
2/144/100/117/121
2/11/130
2/11/131
2/11/132
2/11/133
2/10/134
2/10/135
2/10/136
2/10/137
2/138
2/138/139
2/138/140
2/138/142
2/144
2/144/145
2/144/146
6/7/147/153
6/7/147/154
6/159
6/159/164
6/159/167
6/168/169
6/168/170
6/168/179
6/168/181
6/168/183
6/184
6/184/185
6/184/189
190/193
190/194
190/196
190/197
190/198
190/199
190/201
190/202
190/203
2/245/246
248/249/252
12/13/44/46/294
12/13/44/46/296
299
301
248/361/362
248/361/364
2/144/366
6/367/368
6/184/378
299/382
299/383
299/383/384
299/385
190/386
299/387
299/389
248/395/396
2/144/400
299/401
299/383/402
2/144/458/403/404
2/405
299/412
299/412/413
190/191/419
190/420
299/421
299/422/423
190/424
6/425/427
190/428
190/429
299/431
2/432
6/438/439/442
6/445
6/445/446
6/445/446/448
6/445/446/450
6/438/454
6/438/454/455
2/144/100/457
6/184/465
6/184/465/468
207/469/470
207/469/470/473
6/445/446/482
248/249/253/489
207/513/516
2/11/523
6/168/529
248/544
248/544/545
2/144/549
12/555
299/383/560
12/555/564
299/412/565
2/578
12/582
6/7/147/584
2/10/135/586
2/589/590
2/589/591