4 ms·
I'm not sure if I understand you correctly, but logically the WHERE clause happens before the SELECT clause[1], so it only calculates this value for the rows yo
by taffer 7y ago
I'm not sure if I understand you correctly, but logically the WHERE clause happens before the SELECT clause[1], so it only calculates this value for the rows you're interested in. It is also possible to index functions without generated columns.
[1] https://blog.jooq.org/2016/12/09/a-beginners-guide-to-the-true-order-of-sql-operations/ https://blog.jooq.org/2016/12/09/a-beginners-guide-to-the-tr...
- philliphaydon 7y agoThe first part I’m saying is a bad example because you wouldn’t store the price + vat in a column let alone a calculated column. The second part I’m giving an example where doing: where created + period > now() - '3 days'::interval Having to calculate the value in a where clause is inefficient. Making a calculated column adding created and period then indexing it is more efficient.