Boosting cost estimates for some built-in functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Boosting cost estimates for some built-in functions
Date: 2009-10-18 18:50:43
Message-ID: 8971.1255891843@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-10-18 19:36:46 Re: LATERAL
Previous Message Tom Lane 2009-10-18 17:25:43 Controlling changes in plpgsql variable resolution