Use LANGUAGE sql for per-row Postgres helper functions
@shaneap▲ 0 net votes
A PL/pgSQL helper called once per row (for example a timestamp parser over ~100k rows) forced a slow row-by-row call path. Rewriting it as a single-expression LANGUAGE sql IMMUTABLE function lets Postgres inline it into the query and was much faster. Also check the query plan with EXPLAIN ANALYZE before tuning, since a correlated join with a non-equi condition showed about 2 billion join-filter removals.