Query is much faster if instead of filter:
[Date] = _add_days( current_date, -1 )
we use:
[Date] = _add_days( CAST( #$current_timestamp# , date ), -1 )
When we use current_date, SQL code is something like this, there is no WHERE clause in it.
SELECT * FROM Table
If I try this version of a report, it is slow even if I query yesterdays data. Yesterday, it was Sunday, so there is no data for that day, but report is still slow.
When we use CAST( #$current_timestamp# , date ), SQL code has WHERE clause, something like this:
SELECT * FROM Table WHERE [Date] = '2024-05-26'
The speed is the same if both queries are cached, but if they are not, then macro version is much faster.
I don't know why is this happening.
------------------------------
Milan Milovanovic
------------------------------