On 1 February 2018 at 08:49, Konstantin Knizhnik
<k.knizh...@postgrespro.ru> wrote:
>
>
> On 01.02.2018 03:10, Simon Riggs wrote:
>>
>> On 10 January 2018 at 09:54, Konstantin Knizhnik
>> <k.knizh...@postgrespro.ru> wrote:
>>
>>> (new version attached)
>>
>> Why this comment?
>>
>> Current implementation of projection optimization has to calculate
>> index expression twice
>> in case of hit (value of index expression is not changed) and three
>> times if values are different.
>>
>> Old + New for check = 2
>> plus calculate again in index = 3
>> ?
>>
> Sorry, I do not completely understand your question.
> You do not agree with this statement or you think that this comment is
> irrelevant in this place?
> Or you just want to understand why index expression is calculated 2/3 times?
> If so, then you have answered this question yourself:
>>
>> Old + New for check = 2
>> plus calculate again in index = 3
>
>
> Yes, we have to calculate the value of index expression for original and
> updated version of the record. If them are equal, then it is all we have to
> do with this index: hot update is applicable.
> In this case we calculate index expression twice.
> But if them are not equal, then hot update is not applicable and we have to
> update index. In this case expression will be calculated one more time. So
> totally three times.
> This is why, if calculation of index expression is very expensive, then
> effect of this optimization may be negative even if value of index
> expression is not changed.

OK, thanks. Just checking my understanding and will add to the
comments in the patch.

-- 
Simon Riggs                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Reply via email to