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

Query time 0.00078

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "21.43"
    },
    "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": 46,
          "rows_produced_per_join": 46,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.73",
            "eval_cost": "4.60",
            "prefix_cost": "5.33",
            "data_read_per_join": "736"
          },
          "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": 46,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "11.50",
            "eval_cost": "4.60",
            "prefix_cost": "21.43",
            "data_read_per_join": "120K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
2
2/17
2/18
3/87
109
109/116
109/117
109/118
109/123
2/13/131
2/17/147
2/17/148
2/19/157
2/18/170
2/18/173
2/18/175
4/179
4/179/257
12/58/294
1094
1096
1353/1099
1353/1100
1353/1101
1353/1103
1353/1105
1106
1353/1107
1353/1108
1097/1109
1097/1111
1097/1114
1096/1256
1353/1286
1353
1097/1623
1097/1624
1097/1625
1096/2012
5/2185
1097/2186
1097/2189
1353/2190
3125/3126
1097/4459
16320