Are PostgreSQL functions generally faster than code?

Viewed 388

We all know that it's more performant to use WHERE's over filtering on the app side. But is it more performant to use PostgreSQL functions over app code? Here's a reference example:

Given an array = [1, 2, NULL]...

array_remove(array, NULL)

vs.

result = SQL.execute(array); result.remove_null_values()

Assuming I have to run code in the app anyways, is it really worthwhile to move every single code into SQL? As in, getting major performance (> 10%).

2 Answers
Related