Boosting cost estimates for some built-in functions - Mailing list pgsql-hackers

From Tom Lane
Subject Boosting cost estimates for some built-in functions
Date
Msg-id 8971.1255891843@sss.pgh.pa.us
Whole thread Raw
Responses Re: Boosting cost estimates for some built-in functions
List 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


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Controlling changes in plpgsql variable resolution
Next
From: Robert Haas
Date:
Subject: Re: LATERAL