Consider an SQL query with the following WHERE
clause:
WHERE expires >= DATE_FORMAT(NOW(), '%Y%m%d')
Will the result of DATE_FORMAT()
be recalculated for each row, or will it be calculated once and used for each row? If the latter, I can calculate the value in Python and then inject it into the SQL sent to MySQL.
Due to application restraints, the value is actually a LONGTEXT
column and this question is a simplification of the problem. The data must be stored in this column type due to the EAV nature of the table.
This question pertains to MySQL 5.7, but if other database management systems, particularly SQLite or Postgres have different behaviour then I would appreciate knowing that as well. Thank you.