SELECT 
  p.product_id 
FROM 
  cscart_products as p 
  LEFT JOIN cscart_products_categories as pc ON p.product_id = pc.product_id 
  LEFT JOIN cscart_categories as c ON c.category_id = pc.category_id 
WHERE 
  1 
  AND pc.category_id IN (302, 311, 312, 313) 
  AND p.status = 'A' 
  AND c.status = 0 
  AND p.parent_product_id = 0

Query time 0.00053

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "2.27"
    },
    "nested_loop": [
      {
        "table": {
          "table_name": "c",
          "access_type": "range",
          "possible_keys": [
            "PRIMARY",
            "p_category_id"
          ],
          "key": "p_category_id",
          "used_key_parts": [
            "category_id"
          ],
          "key_length": "3",
          "rows_examined_per_scan": 4,
          "rows_produced_per_join": 0,
          "filtered": "10.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "1.77",
            "eval_cost": "0.04",
            "prefix_cost": "1.81",
            "data_read_per_join": "1K"
          },
          "used_columns": [
            "category_id",
            "status"
          ],
          "attached_condition": "((`kcoffee`.`c`.`category_id` in (302,311,312,313)) and (`kcoffee`.`c`.`status` = 0))"
        }
      },
      {
        "table": {
          "table_name": "pc",
          "access_type": "ref",
          "possible_keys": [
            "PRIMARY",
            "pt"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "category_id"
          ],
          "key_length": "3",
          "ref": [
            "kcoffee.c.category_id"
          ],
          "rows_examined_per_scan": 2,
          "rows_produced_per_join": 0,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.10",
            "eval_cost": "0.08",
            "prefix_cost": "1.99",
            "data_read_per_join": "12"
          },
          "used_columns": [
            "product_id",
            "category_id"
          ],
          "attached_condition": "(`kcoffee`.`pc`.`product_id` is not null)"
        }
      },
      {
        "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": [
            "kcoffee.pc.product_id"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 0,
          "filtered": "96.32",
          "cost_info": {
            "read_cost": "0.20",
            "eval_cost": "0.08",
            "prefix_cost": "2.27",
            "data_read_per_join": "3K"
          },
          "used_columns": [
            "product_id",
            "status",
            "parent_product_id"
          ],
          "attached_condition": "((`kcoffee`.`p`.`parent_product_id` = 0) and (`kcoffee`.`p`.`status` = 'A'))"
        }
      }
    ]
  }
}

Result

product_id
358
359
360
361
362
363
364
365
345
346
366
367
368
369
370
371