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

Query time 0.00120

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "64.26"
    },
    "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": 141,
          "rows_produced_per_join": 141,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.81",
            "eval_cost": "14.10",
            "prefix_cost": "14.91",
            "data_read_per_join": "2K"
          },
          "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": 141,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "35.25",
            "eval_cost": "14.10",
            "prefix_cost": "64.26",
            "data_read_per_join": "369K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      }
    ]
  }
}

Result

id_path
3
5
3/22
5/25
5/27
5/28
8/39
8/42
4/45
4/52
5/62
71
71/73
71/75
4/76
78
3/87
5/96
5/97
78/105
78/106
78/108
109
109/112
109/114
109/115
109/116
109/117
109/118
2/16/143
3/178
4/179
4/45/183
4/45/194
4/46/195
4/46/205
4/46/206
4/46/208
4/100/210
4/100/211
4/52/228
4/51/250
4/179/265
4/179/266
4/275
3/21/336
2896/2528
2896/2529
2530/2532
2896/2890
2896/2890/2891
2896/2893
2896/2893/2894
2896/2893/2895
2896
2896/2890/2898
2896/2899/2900
2896/2899/2901
2896/2902
2896/2903
2530/2909
2530/2911
2530/2913
2530/2914
2530/2915
2530/2916
2530/2918/2919
2530/2918/2920
2530/2918/2921
2530/2928/2929
2530/2928/2930
2530/2932
2530/2943
2530/2944
2530/2945
2530/2945/2946
2530/2945/2947
2530/2948/2949
2531/2978/2951
2530/2948/2952
2530/2953
2530/2954
2531/2955
2531/2956
2531/2957
2530/2958
2530/2959
2531/2960
2530/2961
2531/2962
2531/2963
2531/2964
2531/2965
2531/2966
2531/2967
2531/2968
2531/2969
2531/2970
2531/2970/2971
2531/2970/2972
2531/2970/2973
2531/2974
2531/2975
2531/2978/2977
2531/2979
2531/2980
2531/2980/2981
2531/2980/2982
2531/2983/2984
2531/2983/2985
2530/2928/2986
2892/2987
2892/2988
2892/2989
2896/2991
2530/2993
2896/2899/2995
2530/2918/3007
2531/2970/3008
2530/2948/3009
2531/2978/3010
2531/2978/3011
2530/2918/3012
2531/2970/3014
2530/2948/3015
2531/2978/3016
2531/2978/3017
2530/2948/3018
5/62/6658
5/92/6672
8/6790/6792
7760
11369
11369/11372
11369/11373
11369/11374