Re: [HACKERS] Surjective functional indexes - Mailing list pgsql-hackers

From Konstantin Knizhnik
Subject Re: [HACKERS] Surjective functional indexes
Date
Msg-id a1962a84-70aa-939d-9a1e-63b954ed3727@postgrespro.ru
Whole thread Raw
In response to Re: [HACKERS] Surjective functional indexes  (Simon Riggs <simon@2ndquadrant.com>)
List pgsql-hackers

On 27.03.2018 22:08, Simon Riggs wrote:
> On 23 March 2018 at 15:54, Simon Riggs <simon@2ndquadrant.com> wrote:
>
>> So please could you make the change?
> Committed, but I still think that change would be good.
>
Thank you.
But I still not sure whether replacement of bitmap with List or array of 
Oids is really good idea.

There are two aspects: size and speed. It seems to me that memory 
overhead is most important.
At least you rejected your own idea about using autotune for this 
parameters because of presence of extra 16 bytes in statistic.
But RelationData structure is even more space critical: its size is 
multiplied by number of relations and backends.
Bitmap seems to provide the most compact representation of the 
projective index list.

Concerning speed aspect, certainly iteration through the list of all 
indexes with checking presence of index in the bitmap is more expensive 
than just direct iteration through Oid
list or array. But since check of bitmap can be done in constant time, 
both approaches have the same complexity. Also for typical case (< 5 
normal indexes for a table and 1-2 functional indexes)
difference in performance can not be measured.

Also bitmap provides convenient interface for adding new members. To 
construct array of Oids I need first to determine number of indexes, so 
I have to perform two loops.

So if you and Alvaro insist on this change, then I will definitely do 
it. But from my point of view, using bitmap here is acceptable solution.



-- 
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: [HACKERS] why not parallel seq scan for slow functions
Next
From: Andres Freund
Date:
Subject: Re: Proposal: http2 wire format