On 24 March 2018 at 14:35, Andres Freund <andres@xxxxxxxxxxx> wrote: > How long does planning take if you repeat this? I wonder if a good chunk > of those 1.8s is initial loading of plv8. Maybe, but it also could be the execution of the function, after all, the planner does invoke immutable functions: # explain verbose select lower('TEST'); QUERY PLAN ------------------------------------------- Result (cost=0.00..0.01 rows=1 width=32) Output: 'test'::text (2 rows) Would be interesting to see what changes without the IMMUTABLE flag. -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services