I have to delete rows in a table based on multiple comparisons with a really long function application on one of the columns. To go a bit into details, i'm decoding from base64, doing a substring, transforming to json, taking a specific field, then transforming that to inet.
I'm using those ips to compare with other ips / masks in my WHERE clause.
The problem i have is that obtaining the actual result is a pretty long string, and if i end up saying ip < foo(bar(baz(quux))) OR ip2 < foo(bar(baz(quux))) then that value for comparison will end up being calculated multiple times too.
I'm looking for a way to precompute that value, assign it a meaningful name, then use that name in my WHERE clause.
Thank you