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

Query time 0.00780

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "26.45"
    },
    "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": 57,
          "rows_produced_per_join": 57,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.80",
            "eval_cost": "5.70",
            "prefix_cost": "6.50",
            "data_read_per_join": "912"
          },
          "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": 57,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "14.25",
            "eval_cost": "5.70",
            "prefix_cost": "26.45",
            "data_read_per_join": "149K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
3
4
3/14
3/20
3/21
3/22
4/45
4/46
4/48
4/52
12/59
71/72
3/84
3/85
3/86
109
109/110
109/112
109/118
3/130
2/19/157
3/178
4/47/218
4/48/236
4/125/270
3/20/334
3/22/357
3/14/367
3/84/380
3/85/383
3/86/388
3/20087/395
543
544
545
547
548
544/550
543/552
543/553
543/555
543/557
543/558
544/559
545/561
545/563
545/565
545/566
1812
1813
4/51/6638
8281
8282
8282/8284
8282/8285
8662
545/13340