MYSQL DATE function runs insanely slower in LEFT JOIN

When adding a line:

LEFT JOIN core_records_sales as sales ON DATE(appointments.date) = DATE(sales.date_sold)

At my request, this speeds up the time for the script to run from 8 seconds to 2-3 minutes.

Will there be any data causing this problem, or am I implementing this function incorrectly?

I need to use DATE () because I need them to be on the same day, but the date fields are DATETIME

+3
source share
3 answers

This is almost certainly a problem with the assignments.date field index. Adding the use of the DATE () function ensures that the index cannot be used, forcing a table scan.

, , , ( ) .

, .

+2

? , , , .

EXPLAIN, , .

+1

, , , . ( ), EXPLAIN, , .

0

Source: https://habr.com/ru/post/1723396/


All Articles