Hi. I want do do a select based on a date column and a days column of type INT (no, not to be changed). For this it needs some math.
But I just wonder about the cost of the two variants:
SELECT * FROM table WHERE CAST(NOW() - CREATIONDATE AS INT) > DURATION * 86400
SELECT * FROM table WHERE NOW() > CREATIONDATE + CONCAT(DURATION::text, ' days')::INTERVAL
Both do the same, but I think that the second one has more cost because of the concat and string parsing while the numeric one is just substraction and multiplication.
Can someone explain to me, which and why one os better than the other? Or is it the same?