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

Query time 0.00077

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "28.71"
    },
    "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": 62,
          "rows_produced_per_join": 62,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.81",
            "eval_cost": "6.20",
            "prefix_cost": "7.01",
            "data_read_per_join": "992"
          },
          "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": 62,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "15.50",
            "eval_cost": "6.20",
            "prefix_cost": "28.71",
            "data_read_per_join": "162K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
2
4
5
2/15
23
23/31
23/38/37
8/40
4/45
4/50
4/52
71/73
4/100
109/118
2/13/132
4/45/184
4/45/185
4/45/187
4/45/191
4/46/199
4/100/213
4/100/214
4/52/230
4/48/242
4/45/6634
4/6639
8/40/6740
4/6639/11179
11965
12082
12086/12083/12084
12086/12083/12085
12086/12087
12086/12083/12088
12086/12083/12089
12090
12108/12109
12108/12110
12108/12111
12108/12112
12108/12113
12114
12115
12116
12117
12118
12108/13045
12086/12083/13244
12086/12083/13302
12086/12083/13303
12086/12083/13304
12086/12083/13305
12086/12083/13306
12086/12083/13308
12086/12083/13309
12956/13311
12956/13312
13512
12086/12083/13571
12086/12083/13572
12086/12083/13573
23/38/37/22887