Eliminate MySQL CAST on datetime columns when expected value type is datetime.
CAST method would allow converting from one datatype to other datatype. This would be useful when requirement demands diffent type of data compared to column data.
Example
Lets say there is a requirement to show data of created time of record only, then from createdtime column we need to extract only date component. This can be achieved in multiple ways. One of them is to use CAST method within SELECT query and fetch only date component from the column.
As MySQL built-in methods are costly on bigger datasets, making use of built-in methods when not required would add more load on MySQL in processing phase.
In Vtiger, there are certain places where we are using CAST on a datetime column to get datetime value which is not necessary and adding unnecessary load for bigger databases as it is more evident.
Areas to review
- Querygenerators
- CustomView
- Reports (all types)
- Calendar