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

Query time 0.00065

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "18.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": 40,
          "rows_produced_per_join": 40,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.96",
            "eval_cost": "4.00",
            "prefix_cost": "4.96",
            "data_read_per_join": "640"
          },
          "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": 40,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "10.00",
            "eval_cost": "4.00",
            "prefix_cost": "18.96",
            "data_read_per_join": "104K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
2
8
3/14
2/17
2/18
8/40
4/45
4/46
71
71/72
71/74
78
3/85
3/87
71/88
2/17/147
2/18/175
2/18/176
4/46/195
4/46/205
4/46/206
4/46/208
4/51/253
12/59/311
3/22/349
3/22/357
3/14/368
3/86/388
4932
4933
4934
4935
4933/4937
4939
4939/4940
4/46/195/22740/7651
4939/8274
3/14/10891
11030
12955