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

Query time 0.00089

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "36.96"
    },
    "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": 80,
          "rows_produced_per_join": 80,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.96",
            "eval_cost": "8.00",
            "prefix_cost": "8.96",
            "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": 80,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "20.00",
            "eval_cost": "8.00",
            "prefix_cost": "36.96",
            "data_read_per_join": "209K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
2
4
5
2/13
3/14
2/15
2/17
3/20
23
5/26
5/27
23/33
23/38
71
78
2/81
2/82
3/87
5/96
78/108
109
109/110
109/111
109/112
109/114
109/115
109/116
109/117
109/118
109/121
109/123
2/13/131
2/13/132
2/13/133
2/13/137
2/17/147
2/17/149
2/81/155
2/15/168
2/15/169
2/18/170
2/18/171
2/18/173
2/18/175
3/178
4/45/183
4/45/185
4/45/191
4/45/192
4/48/236
4/48/238
4/48/241
4/48/243
4/179/259
4/179/266
2/326
5/2185
2566
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4887
4888