SELECT 
  p.promotion_id, 
  p.from_date, 
  p.to_date, 
  active.from_date AS active_from_date, 
  active.to_date AS active_to_date, 
  expired.from_date AS expired_from_date, 
  expired.to_date AS expired_to_date 
FROM 
  cscart_promotions AS p 
  INNER JOIN cscart_ab__dotd AS ab__dotd ON p.promotion_id = ab__dotd.promotion_id 
  AND ab__dotd.use_schedule = 'Y' 
  LEFT JOIN (
    SELECT 
      promotion_id, 
      MIN(from_date) AS from_date, 
      MIN(to_date) AS to_date 
    FROM 
      cscart_ab__dotd_periods 
    WHERE 
      to_date >= 1733951937 
    GROUP BY 
      promotion_id
  ) AS active ON active.promotion_id = p.promotion_id 
  LEFT JOIN (
    SELECT 
      promotion_id, 
      MAX(from_date) AS from_date, 
      MAX(to_date) AS to_date 
    FROM 
      cscart_ab__dotd_periods 
    WHERE 
      to_date < 1733951937 
    GROUP BY 
      promotion_id
  ) AS expired ON expired.promotion_id = p.promotion_id 
WHERE 
  p.status IN ('A', 'H')

Query time 0.00109

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "5.64"
    },
    "nested_loop": [
      {
        "table": {
          "table_name": "ab__dotd",
          "access_type": "ALL",
          "possible_keys": [
            "PRIMARY"
          ],
          "rows_examined_per_scan": 10,
          "rows_produced_per_join": 1,
          "filtered": "10.00",
          "cost_info": {
            "read_cost": "2.80",
            "eval_cost": "0.20",
            "prefix_cost": "3.00",
            "data_read_per_join": "32"
          },
          "used_columns": [
            "promotion_id",
            "use_schedule"
          ],
          "attached_condition": "(`eshopuga_upgr_4122`.`ab__dotd`.`use_schedule` = 'Y')"
        }
      },
      {
        "table": {
          "table_name": "p",
          "access_type": "eq_ref",
          "possible_keys": [
            "PRIMARY"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "promotion_id"
          ],
          "key_length": "3",
          "ref": [
            "eshopuga_upgr_4122.ab__dotd.promotion_id"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 0,
          "filtered": "20.00",
          "cost_info": {
            "read_cost": "1.00",
            "eval_cost": "0.04",
            "prefix_cost": "4.20",
            "data_read_per_join": "16"
          },
          "used_columns": [
            "promotion_id",
            "to_date",
            "from_date",
            "status"
          ],
          "attached_condition": "(`eshopuga_upgr_4122`.`p`.`status` in ('A','H'))"
        }
      },
      {
        "table": {
          "table_name": "active",
          "access_type": "ref",
          "possible_keys": [
            "<auto_key0>"
          ],
          "key": "<auto_key0>",
          "used_key_parts": [
            "promotion_id"
          ],
          "key_length": "3",
          "ref": [
            "eshopuga_upgr_4122.ab__dotd.promotion_id"
          ],
          "rows_examined_per_scan": 2,
          "rows_produced_per_join": 0,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.40",
            "eval_cost": "0.08",
            "prefix_cost": "4.68",
            "data_read_per_join": "9"
          },
          "used_columns": [
            "promotion_id",
            "from_date",
            "to_date"
          ],
          "materialized_from_subquery": {
            "using_temporary_table": true,
            "dependent": false,
            "cacheable": true,
            "query_block": {
              "select_id": 2,
              "cost_info": {
                "query_cost": "1.20"
              },
              "grouping_operation": {
                "using_filesort": false,
                "table": {
                  "table_name": "cscart_ab__dotd_periods",
                  "access_type": "index",
                  "possible_keys": [
                    "PRIMARY"
                  ],
                  "key": "PRIMARY",
                  "used_key_parts": [
                    "promotion_id",
                    "from_date"
                  ],
                  "key_length": "7",
                  "rows_examined_per_scan": 1,
                  "rows_produced_per_join": 1,
                  "filtered": "100.00",
                  "cost_info": {
                    "read_cost": "1.00",
                    "eval_cost": "0.20",
                    "prefix_cost": "1.20",
                    "data_read_per_join": "16"
                  },
                  "used_columns": [
                    "promotion_id",
                    "from_date",
                    "to_date"
                  ],
                  "attached_condition": "(`eshopuga_upgr_4122`.`cscart_ab__dotd_periods`.`to_date` >= 1733951937)"
                }
              }
            }
          }
        }
      },
      {
        "table": {
          "table_name": "expired",
          "access_type": "ref",
          "possible_keys": [
            "<auto_key0>"
          ],
          "key": "<auto_key0>",
          "used_key_parts": [
            "promotion_id"
          ],
          "key_length": "3",
          "ref": [
            "eshopuga_upgr_4122.ab__dotd.promotion_id"
          ],
          "rows_examined_per_scan": 2,
          "rows_produced_per_join": 0,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.80",
            "eval_cost": "0.16",
            "prefix_cost": "5.64",
            "data_read_per_join": "19"
          },
          "used_columns": [
            "promotion_id",
            "from_date",
            "to_date"
          ],
          "materialized_from_subquery": {
            "using_temporary_table": true,
            "dependent": false,
            "cacheable": true,
            "query_block": {
              "select_id": 3,
              "cost_info": {
                "query_cost": "1.20"
              },
              "grouping_operation": {
                "using_filesort": false,
                "table": {
                  "table_name": "cscart_ab__dotd_periods",
                  "access_type": "index",
                  "possible_keys": [
                    "PRIMARY"
                  ],
                  "key": "PRIMARY",
                  "used_key_parts": [
                    "promotion_id",
                    "from_date"
                  ],
                  "key_length": "7",
                  "rows_examined_per_scan": 1,
                  "rows_produced_per_join": 1,
                  "filtered": "100.00",
                  "cost_info": {
                    "read_cost": "1.00",
                    "eval_cost": "0.20",
                    "prefix_cost": "1.20",
                    "data_read_per_join": "16"
                  },
                  "used_columns": [
                    "promotion_id",
                    "from_date",
                    "to_date"
                  ],
                  "attached_condition": "(`eshopuga_upgr_4122`.`cscart_ab__dotd_periods`.`to_date` < 1733951937)"
                }
              }
            }
          }
        }
      }
    ]
  }
}