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

Query time 0.00089

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "31.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": 69,
          "rows_produced_per_join": 69,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.74",
            "eval_cost": "6.90",
            "prefix_cost": "7.64",
            "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": 69,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "17.25",
            "eval_cost": "6.90",
            "prefix_cost": "31.79",
            "data_read_per_join": "180K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
2
8
2/13
2/16
3/21
5/27
2/82
109/110
109/111
109/112
109/114
109/116
109/117
109/118
2/13/131
2/13/132
2/13/134
2/13/136
2/13/137
2/16/138
2/16/139
2/16/141
2/16/144
2/17/147
2/17/150
2/19/158
2/18/170
2/18/171
2/18/173
2/18/174
2/18/175
2/326
3/130/366
3/85/387
527
525/528
525/529
525/530
525/531
525/532
525/533
527/534
527/535
551
747
748
749/1409
749/1410
749/1411
749/1412
749/1413
749/1414
749/1415
749/1416
749/1417
749/1418
749/1419
525/1420
525/1421
749/3637
525/13821
525/15493
21236
21415
525/21453
12/319/320/22815