Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dFE2I-0005aJ-2h for pgsql-hackers@arkaria.postgresql.org; Mon, 29 May 2017 06:20:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dFE2H-0002NU-LV for pgsql-hackers@arkaria.postgresql.org; Mon, 29 May 2017 06:20:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dFE2F-0002K1-GN for pgsql-hackers@postgresql.org; Mon, 29 May 2017 06:20:11 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dFE28-0008Mv-AZ for pgsql-hackers@postgresql.org; Mon, 29 May 2017 06:20:10 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 569FC21C174E; Mon, 29 May 2017 09:20:01 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Message-ID: <592BBD90.3060104@postgrespro.ru> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1496038801; bh=Y/gXy7hdhQvLCjN1cBLl+IfD7I0j71evJp+XW9Tlgnw=; h=Date:From:To:Subject:References:In-Reply-To; b=jt7hTxi0q060/Bp25b0Us+KwGY2a/TQPU3c9VJhzX/4AJMPNaBS+y2z+BzR9rVpDi 5CA4PFtzhQtOHYuBzmLRkoB99oslq4faVqkVVmrSYpxkSdVgcYlbRIVi4Nr+2LcVya nq59qYXuC6TB73lXH0cFTiO4HnQ0MeovSk+GNZvs= Date: Mon, 29 May 2017 09:20:00 +0300 From: Konstantin Knizhnik User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Peter Eisentraut , PostgreSQL Hackers Subject: Re: Surjective functional indexes References: <4d9928ee-a9e6-15f9-9c82-5981f13ffca6@postgrespro.ru> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 05/27/2017 09:50 PM, Peter Eisentraut wrote: > On 5/25/17 12:30, Konstantin Knizhnik wrote: >> Functions like (info->>'name') are named "surjective" ni mathematics. > A surjective function is one where each value in the output type can be > obtained by some input value. That's not what you are after here. The > behavior you are describing is a not-injective function. > > I think you are right that in practice most functions are not injective. > But I think there is still quite some difference between a function > like the one you showed that selects a component from a composite data > structure and, for example, round(), where in practice any update is > likely to change the result of the function. > Thank you, I will rename "surjective" parameter to "injective" with "false" as default value. Concerning "round" and other similar functions - obviously there are use cases when such functions are used for functional indexes. This is why I want to allow user to make a choice and this is the reason of introducing this parameter. The question is the default value of this parameter: should we by default preserve original Postgres behavior: check only affected set of keys or should we pay extra cost for calculating value of the function (even if we managed to store calculated value of the indexes expression for new tuple, we still have to calculate it for old tuple, so function will be calculated at least twice more times). -- Konstantin Knizhnik Postgres Professional: http://www.postgrespro.com The Russian Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers