Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XkL0G-0005hl-Ay for pgsql-hackers@arkaria.postgresql.org; Fri, 31 Oct 2014 22:49:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XkL0F-0007Us-Rx for pgsql-hackers@arkaria.postgresql.org; Fri, 31 Oct 2014 22:49:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XkL0E-0007Uk-D9 for pgsql-hackers@postgresql.org; Fri, 31 Oct 2014 22:49:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XkL03-0006l3-1B for pgsql-hackers@postgresql.org; Fri, 31 Oct 2014 22:49:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s9VMmjMO012337; Fri, 31 Oct 2014 18:48:45 -0400 From: Tom Lane To: Andres Freund cc: pgsql-hackers@postgresql.org Subject: Re: _mdfd_getseg can be expensive In-reply-to: <20141031223210.GN13584@awork2.anarazel.de> References: <20140331101001.GE13135@alap3.anarazel.de> <20141031223210.GN13584@awork2.anarazel.de> Comments: In-reply-to Andres Freund message dated "Fri, 31 Oct 2014 23:32:10 +0100" Date: Fri, 31 Oct 2014 18:48:45 -0400 Message-ID: <12336.1414795725@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) 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 Andres Freund writes: > I wrote the attached patch that get rids of that essentially quadratic > behaviour, by replacing the mdfd chain/singly linked list with an > array. Since we seldomly grow files by a whole segment I can't see the > slightly bigger memory reallocations matter significantly. In pretty > much every other case the array is bound to be a winner. > Does anybody have fundamental arguments against that idea? While the basic idea is sound, this particular implementation seems pretty bizarre. What's with the "md_seg_no" stuff, and why is that array typed size_t? IOW, why didn't you *just* replace the linked list with an array? This patch seems to be making some other changes that you've failed to explain. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers