On 2017-05-25 12:37:40 -0400, Tom Lane wrote:
> Konstantin Knizhnik <k.knizhnik@postgrespro.ru> writes:
> > My proposal is to check value of function for functional indexes instead
> > of just comparing set of effected attributes.
> > Obviously, for some complex functions it may have negative effect on
> > update speed.
> > This is why I have added "surjective" option to index.
>
> This seems overcomplicated. We would have to compute the function
> value at some point anyway. Can't we refactor to do that earlier?
Yea, that'd be good. Especially if we were to compute the expressions
for all indexes in one go - doing that in other places (e.g. aggregate
transition values) yielded a good amount of speedup. It'd be even
larger if we get JITing of expressions. It seems feasible to do so for
at least the nodeModifyTable case.
I wonder if there's a chance to use such logic alsofor HOT update
considerations, but that seems harder to do without larger layering
violations.
- Andres