We recently saw a complaint about psql \d commands being quite slow with many tables, which turned out to be because the planner was putting a table_has_privilege() call where it would get executed a lot, before other cheaper tests on pg_class. This is not the planner's fault --- it has no information that would suggest that table_has_privilege() is any more expensive than any other built-in function.
In another case I was looking at just now, it seems that to_tsquery() and to_tsvector() are noticeably slower than most other built-in functions, which is not surprising given the amount of mechanism that gets invoked inside them. It would be useful to tell the planner about that to discourage it from picking seqscan plans that involve repeated execution of these functions. I'd like to suggest boosting the built-in cost estimates for the xxx_has_privilege functions to perhaps 10. to_tsquery and to_tsvector maybe should be boosted even higher, but I don't have a good specific number in mind. Thoughts? regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers