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

Query time 0.00062

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "10.97"
    },
    "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": 23,
          "rows_produced_per_join": 23,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.62",
            "eval_cost": "2.30",
            "prefix_cost": "2.92",
            "data_read_per_join": "368"
          },
          "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": 23,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "5.75",
            "eval_cost": "2.30",
            "prefix_cost": "10.97",
            "data_read_per_join": "60K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
2
2/15
12/54
3/85
3/87
4/179/261
4/179/262
4/99/271
12/54/295
12/59/317
3/85/387
18154
18155
18155/18158
18159
18154/18160
18154/18161
18154/18162
18154/18163
18154/18164
18340
19271
19644