What potential pitfalls should be considered when using DATE_FORMAT in the WHERE clause?

When using DATE_FORMAT in the WHERE clause, it's important to consider the potential performance impact. Since using DATE_FORMAT can prevent the query optimizer from using indexes efficiently, it may result in slower query execution times. To mitigate this issue, it's recommended to avoid using DATE_FORMAT in the WHERE clause if possible, or to ensure that the column being filtered is indexed properly.

// Example of avoiding DATE_FORMAT in WHERE clause
$query = "SELECT * FROM table WHERE date_column >= '2022-01-01' AND date_column <= '2022-12-31'";
$result = mysqli_query($connection, $query);