Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cu0wQ-0002Zz-7b for pgsql-hackers@arkaria.postgresql.org; Fri, 31 Mar 2017 18:06:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cu0wP-0005fq-QQ for pgsql-hackers@arkaria.postgresql.org; Fri, 31 Mar 2017 18:06:29 +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 1cu0ut-00005N-Cf for pgsql-hackers@postgresql.org; Fri, 31 Mar 2017 18:04:55 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cu0uo-00058Q-P4 for pgsql-hackers@postgresql.org; Fri, 31 Mar 2017 18:04:54 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id E319721C2438; Fri, 31 Mar 2017 21:04:49 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Received: from [10.10.6.144] (unknown [208.123.164.34]) by mail.postgrespro.ru (Postfix) with ESMTPSA id 78EFB21C0647; Fri, 31 Mar 2017 21:04:48 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1490983489; bh=efqoU8jg/HIuQKosZTDF31htdzjPRH7QGe1MrQvwSI8=; h=Subject:To:References:Cc:From:Date:In-Reply-To; b=J7S1IIjWGu+UQnFujpvtX0uS0GU3z7jPVsEBQvM+ktlbK77e1sQqbpsawTOrnbwOa gtYoumXcTK+Iu9I7V0wf/Sb9K6Lm+AKOJHcvzR9T2DQpYn/HaRLk7/Sth6WP19AEwT FbcovKpF4S5mI6SXSsr0mNxkM8u4hlzQWDlr3mtI= Subject: Re: WIP: Covering + unique indexes. To: Andres Freund References: <56168952.4010101@postgrespro.ru> <46e1f13e-6887-3851-a525-f046029341eb@postgrespro.ru> <20170324124709.22419.51178.pgcf@coridan.postgresql.org> <20170330191138.zawsxgsxnt2qy2as@alap3.anarazel.de> <20170331174728.4hpwklu46qwcrfwa@alap3.anarazel.de> Cc: Teodor Sigaev , pgsql-hackers@postgresql.org, Anastasia Lubennikova , Peter Geoghegan , David Steele , Peter Eisentraut , Aleksander Alekseev From: Anastasia Lubennikova Message-ID: Date: Fri, 31 Mar 2017 21:04:46 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170331174728.4hpwklu46qwcrfwa@alap3.anarazel.de> Content-Type: multipart/alternative; boundary="------------94B78ACEB10257BEA3451152" 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 This is a multi-part message in MIME format. --------------94B78ACEB10257BEA3451152 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit 31.03.2017 20:47, Andres Freund: >>> Maybe it would be better to modify index_form_tuple() to accept a new >>> argument with a number of attributes, then you can just Assert that >>> this number is never higher than the number of attributes in the >>> TupleDesc. >> Good point. >> I agree that this function is a bit strange. I have to set >> tupdesc->nattrs to support compatibility with index_form_tuple(). >> I didn't want to add neither a new field to tupledesc nor a new >> parameter to index_form_tuple(), because they are used widely. >> >> >> But I haven't considered the possibility of index_form_tuple() failure. >> Fixed in this version of the patch. Now it creates a copy of tupledesc to >> pass it to index_form_tuple. > That seems like it'd actually be a noticeable increase in memory > allocator overhead. I think we should just add (as just proposed in > separate thread), a _extended version of it that allows to specify the > number of columns. The function is called not that often. Only once per page split for indexes with included columns. Doesn't look like dramatic overhead. So I decided that a wrapper function would be more appropriate than refactoring of all index_form_tuple() calls. But index_form_tuple_extended() looks like a better solution. -- Anastasia Lubennikova Postgres Professional: http://www.postgrespro.com The Russian Postgres Company --------------94B78ACEB10257BEA3451152 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 7bit 31.03.2017 20:47, Andres Freund:
Maybe it would be better to modify index_form_tuple() to accept a new
argument with a number of attributes, then you can just Assert that
this number is never higher than the number of attributes in the
TupleDesc.
Good point.
I agree that this function is a bit strange. I have to set
tupdesc->nattrs to support compatibility with index_form_tuple().
I didn't want to add neither a new field to tupledesc nor a new
parameter to index_form_tuple(), because they are used widely.


But I haven't considered the possibility of index_form_tuple() failure.
Fixed in this version of the patch. Now it creates a copy of tupledesc to
pass it to index_form_tuple.
That seems like it'd actually be a noticeable increase in memory
allocator overhead.  I think we should just add (as just proposed in
separate thread), a _extended version of it that allows to specify the
number of columns.

The function is called not that often. Only once per page split for indexes with included columns.
Doesn't look like dramatic overhead. So I decided that a wrapper function would be more appropriate than refactoring of all index_form_tuple() calls.
But index_form_tuple_extended() looks like a better solution.
-- 
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
--------------94B78ACEB10257BEA3451152--