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

Query time 0.00095

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "49.82"
    },
    "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": 109,
          "rows_produced_per_join": 109,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.77",
            "eval_cost": "10.90",
            "prefix_cost": "11.67",
            "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": 109,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "27.25",
            "eval_cost": "10.90",
            "prefix_cost": "49.82",
            "data_read_per_join": "285K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
4
5
2/13
2/17
23/38
4/45
4/46
71
71/73
4/76
2/82
3/87
4/99
78/106
109
109/116
2/13/134
2/13/137
2/17/147
2/15/169
4/45/187
4/45/194
4/46/195
4/46/195/196
4/46/199
4/46/201
4/46/202/22751/204
4/46/206
4/46/207
4/46/208
4/76/227
4/48/243
4/179/258
4/179/259
4/179/267
4/99/272
12/59/317
2/326
3/20/329
3/21/336
2566
4/6644
4/6644/6647
5/62/6655
5/62/6658
5/62/6659
5/26/6692
71/6727/6731
4/7580/7581
4/46/195/22740/7651
21622
21607/21623
21629/21630
21629/21631
21622/21632
21672
21673
21673/21674
21673/21675
21673/21676
21673/21677
21673/21679
21673/21680
21607/21735
21741/21742
21741/21743
21741/21744
21761
21761/21762
21761/21763
21771
21771/21772
21771/21773
21776/21777
21776/21777/21778
21776/21779/21780
21785
21785/21786
21785/21787
21785/21788
21791
21791/21793
21791/21794
21791/21795
21791/21796
21791/21797
21791/21798
21800
21785/21979
21987
21987/21988
21622/21996
22616
22616/22617
22616/22618
22616/22619
21791/22625
4/46/195/22737
4/46/195/22737/22743
4/46/195/22737/22745
4/46/195/22737/22746
22898
23008
23012/23013
23012/23014
23091
23114
23114/23115
23114/23117