Does FROM_UNIXTIME heavily affect the performance of a query like this:
(
(calltasks.task_dueDate = '".$date."') # Tasks of this date
OR
(calltasks.task_dueDate < '".$date."' AND calltasks.task_status = 'scheduled') # Tasks still available on this date
OR
(FROM_UNIXTIME(calltasks.task_executionTime, '%Y-%m-%d') = '".$date."') # Tasks finished this date
)
Or I should be fine with it ??
Rather than converting your UNIX time to a formatted string, then comparing those (as you currently are), you would be better to use
UNIX_TIMESTAMP()to convert your$datevariable to a UNIX time and then compare integers (checking the difference is no more than 24 hours). Integer comparison will always be faster than string comparison:Alternatively, you may find that you already have the UNIX timestamp value of
$datesomewhere readily available in the language from which you are invoking this query: PHP, for example, stores dates as UNIX timestamps.Note that you should be absolutely certain that
$datecannot be manipulated to contain SQL if you are inserting it into your query in this fashion; if there is any doubt, you should use a prepared statement: if you don’t know why, or what they are, read about Bobby Tables.