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

Query time 0.00152

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "17.79"
    },
    "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": 38,
          "rows_produced_per_join": 38,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.69",
            "eval_cost": "3.80",
            "prefix_cost": "4.49",
            "data_read_per_join": "608"
          },
          "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": 38,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "9.50",
            "eval_cost": "3.80",
            "prefix_cost": "17.79",
            "data_read_per_join": "99K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
3
4
3/20
3/21
3/22
4/52
71/72
78
5/97
78/105
78/106
78/107
78/108
109/110
109/112
109/114
109/115
109/116
109/117
109/118
109/121
109/123
109/124
181
3/20/329
3/20/335
3/21/336
3/22/342
3/22/342/346
3/22/349
3/22/349/354
3885
3890
3896
3897
3899
3903