php - How to reduce subquery execution time...? -
i want per day sales item count 1 created query takes around 55.585s , query is
query :
select td.db_date, ( select count(*) order order date(order.created_on) = td.db_date )as day_contribute time_dimension td
so can 1 please let me know how may optimized query , reduce execution time.?
you can modify query join like:
select td.db_date, count(order.id) day_contribute time_dimension td left join order on date(order.created_on) = td.db_date group td.db_date;
i not know primary id key table order - used "order.id". replace your.
also important - test if have index on td.db_date field.
and 1 more important thing - better avoid using date(order.created_on). because mean date() method called each time when db compare dates. if possible - convert order.created_on same format td.db_date. or join other fields. add speed too.
Comments
Post a Comment