SELECT 
  c.*, 
  cd.category as category_name, 
  COUNT(p.product_id) as product_count 
FROM 
  cscart_categories as c 
  LEFT JOIN cscart_category_descriptions as cd ON c.category_id = cd.category_id 
  LEFT JOIN cscart_products_categories as pc ON pc.category_id = c.category_id 
  LEFT JOIN cscart_products as p ON p.product_id = pc.product_id 
  AND p.status = 'A' 
  AND p.parent_product_id = 0 
WHERE 
  c.company_id = 193 
GROUP BY 
  c.category_id 
HAVING 
  product_count > 0 
ORDER BY 
  c.position ASC

Query time 0.00476

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "252853.22"
    },
    "ordering_operation": {
      "using_filesort": true,
      "grouping_operation": {
        "using_temporary_table": true,
        "using_filesort": false,
        "nested_loop": [
          {
            "table": {
              "table_name": "c",
              "access_type": "ALL",
              "possible_keys": [
                "PRIMARY",
                "p_category_id"
              ],
              "rows_examined_per_scan": 1378,
              "rows_produced_per_join": 137,
              "filtered": "10.00",
              "cost_info": {
                "read_cost": "129.74",
                "eval_cost": "13.78",
                "prefix_cost": "143.52",
                "data_read_per_join": "462K"
              },
              "used_columns": [
                "category_id",
                "parent_id",
                "id_path",
                "level",
                "company_id",
                "storefront_id",
                "usergroup_ids",
                "status",
                "product_count",
                "position",
                "timestamp",
                "is_op",
                "localization",
                "age_verification",
                "age_limit",
                "parent_age_verification",
                "parent_age_limit",
                "selected_views",
                "default_view",
                "product_details_view",
                "product_columns",
                "is_trash",
                "is_default",
                "category_type",
                "featured"
              ],
              "attached_condition": "(`cscartdb`.`c`.`company_id` = 193)"
            }
          },
          {
            "table": {
              "table_name": "cd",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "category_id"
              ],
              "key_length": "3",
              "ref": [
                "cscartdb.c.category_id"
              ],
              "rows_examined_per_scan": 13,
              "rows_produced_per_join": 1791,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "447.85",
                "eval_cost": "179.14",
                "prefix_cost": "770.51",
                "data_read_per_join": "5M"
              },
              "used_columns": [
                "category_id",
                "category"
              ]
            }
          },
          {
            "table": {
              "table_name": "pc",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "category_id"
              ],
              "key_length": "3",
              "ref": [
                "cscartdb.c.category_id"
              ],
              "rows_examined_per_scan": 623,
              "rows_produced_per_join": 1116042,
              "filtered": "100.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "7411.92",
                "eval_cost": "111604.22",
                "prefix_cost": "119786.65",
                "data_read_per_join": "17M"
              },
              "used_columns": [
                "product_id",
                "category_id"
              ]
            }
          },
          {
            "table": {
              "table_name": "p",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "status",
                "idx_parent_product_id"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "cscartdb.pc.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 1116042,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "21462.35",
                "eval_cost": "111604.22",
                "prefix_cost": "252853.22",
                "data_read_per_join": "5G"
              },
              "used_columns": [
                "product_id",
                "status",
                "parent_product_id"
              ],
              "attached_condition": "<if>(is_not_null_compl(p), ((`cscartdb`.`p`.`parent_product_id` = 0) and (`cscartdb`.`p`.`status` = 'A')), true)"
            }
          }
        ]
      }
    }
  }
}

Result

category_id parent_id id_path level company_id storefront_id usergroup_ids status product_count position timestamp is_op localization age_verification age_limit parent_age_verification parent_age_limit selected_views default_view product_details_view product_columns is_trash is_default category_type featured category_name
1335 155 155/1335 2 193 0 0 A 4 7480 0 N N 0 N 0 0 N N C OTK Spanking Paddles
1336 155 155/1336 2 193 0 0 A 2 7490 0 N N 0 N 0 0 N N C Straps and Slappers
1337 155 155/1337 2 193 0 0 A 4 7500 0 N N 0 N 0 0 N N C Long Handled Paddles
1338 155 155/1338 2 193 0 0 A 4 7510 0 N N 0 N 0 0 N N C Frat and Sorority Paddles
1339 155 155/1339 2 193 0 0 A 3 7520 0 N N 0 N 0 0 N N C Mid-Size Paddles