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

Query time 0.00054

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "65.19"
    },
    "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": 45,
          "rows_produced_per_join": 45,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "2.19",
            "eval_cost": "9.00",
            "prefix_cost": "11.19",
            "data_read_per_join": "720"
          },
          "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": 45,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "45.00",
            "eval_cost": "9.00",
            "prefix_cost": "65.19",
            "data_read_per_join": "118K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
2/3
2/3/5
12/13
12/13/38
12/13/38/40
12/13/38/43
12/13/44/49
12/50/77
12/50/77/82
12/95/96
2/144/100/113/114
2/144/100/117
2/11/133
2/10/134
2/10/136
2/138/139
2/144/145
6/168
6/168/169
6/168/170
6/168/171
6/168/177
6/168/180
6/168/181
6/168/183
6/184
190
6/168/244
248/249/251
248/249/252
248/249/253
12/13/44/46/298
2/144/366
207/379
190/386
299/387
299/389
248/393
190/428
248/249/434/435
6/438/454/455
6/438/460/464
248/249/484
248/249/253/489
207/513
6/168/518
6/519
2/11/523
2/11/523/525
2/11/523/526
248/249/253/532
248/249/533
248/544/546
190/551
299/552