Don't look up the type oid for types that never use it #168
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Getting function argument type oids can be surprisingly expensive; one Promscale benchmark measures it as taking over 10% of runtime (@cevian should have more info). Fortunately, most types do not actually make use of this information, and the
getarg_type()
call can be optimized out if this fact is known. This commit adds an opt-in method for declaring that a type does not make use of thetypeoid
infrom_datum()
, and updatespg_getarg()
to make use of this information.This commit makes the following changes:
const
boolean toFromDatum
calledNEEDS_TYPID
. This boolean is defaulted totrue
. Types that never use thetypeoid
parameter tofrom_datum()
can override this tofalse
.pg_getarg()
updated to look atT::NEEDS_TYPID
before callingget_getarg_type()
. IfT::NEEDS_TYPID == true
it callsget_getarg_type()
like it currently does for all types; if it isfalse
it instead passesInvalidOid
as the (unused)typeoid
argument tofrom_datum()
.Since this feature is both opt-in and backwards compatible, it should not break any downstream users.