Michael Fuhr <mike@xxxxxxxx> writes: > Try looping through two million rows with PL/Perl or PL/Tcl and > you'll probably see significantly worse performance than with > PL/pgSQL -- so much worse that I'd be surprised to see those languages > make up the difference with whatever processing they'd be doing for > each row unless it was something they're particularly good at and > PL/pgSQL is particularly bad at. I'd expect plpgsql to suck at purely computational tasks, compared to the other PLs, but to win at tasks involving database access. These are two sides of the same coin really --- plpgsql is tightly tied to the PG query execution engine, to the extent of using it even for simply adding 2 and 2, but that also gives it relatively low overhead for invoking a database query. Perl, Tcl, et al have their own computational engines and can easily beat the PG SQL engine for simple arithmetic and string-pushing. But they pay a high overhead for calling back into the database engine. regards, tom lane