Re: [HACKERS] Surjective functional indexes

From: Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Stephen Frost <sfrost(at)snowman(dot)net>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Christoph Berg <myon(at)debian(dot)org>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Surjective functional indexes
Date: 2018-03-28 07:18:38
Message-ID: a1962a84-70aa-939d-9a1e-63b954ed3727@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers

On 27.03.2018 22:08, Simon Riggs wrote:
> On 23 March 2018 at 15:54, Simon Riggs <simon(at)2ndquadrant(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-03-28 08:02:51 Re: Proposal: http2 wire format
Previous Message Amit Kapila 2018-03-28 07:06:33 Re: [HACKERS] why not parallel seq scan for slow functions