> But I've seen that result in queries that are
> slower by an order of magnitude or more, I think because PL/SQL is
> completely opaque to the query optimizer.
Yep. Also, with pl/sql functions, you're crossing boundry from sql query processing to pl/sql function execution. PL/Sql is fundamentally an interpreted language - the code gets tokenize and the tokens interpreted, so you have that overhead as well.