Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hiknx-0006J6-Aq for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Jul 2019 19:20:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hiknv-0006OK-Rn for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Jul 2019 19:20:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hiknv-0006MY-H6 for pgsql-hackers@lists.postgresql.org; Wed, 03 Jul 2019 19:20:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hiknr-0001Z9-KR for pgsql-hackers@lists.postgresql.org; Wed, 03 Jul 2019 19:20:30 +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 x63JKFFo002306; Wed, 3 Jul 2019 15:20:15 -0400 From: Tom Lane To: David Rowley cc: Jesper Pedersen , Andres Freund , Robert Haas , PostgreSQL Hackers Subject: Re: POC: converting Lists into arrays In-reply-to: References: <481.1551390571@sss.pgh.pa.us> <24783.1551568303@sss.pgh.pa.us> <20190303043424.itzy3ge52xrkpmpr@alap3.anarazel.de> <437.1551637744@sss.pgh.pa.us> <12684.1551723095@sss.pgh.pa.us> <20190304190612.vgqqsowzkrh22623@alap3.anarazel.de> <26464.1551734920@sss.pgh.pa.us> <20190304221101.hdg4vj5fo4eewh3b@alap3.anarazel.de> <20190304235402.nod3gbotk2qtd4nh@alap3.anarazel.de> <1131.1551746172@sss.pgh.pa.us> <14626.1558745627@sss.pgh.pa.us> <29297.1558799327@sss.pgh.pa.us> <25178.1562006685@sss.pgh.pa.us> <25258.1562023641@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Wed, 03 Jul 2019 18:56:25 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2304.1562181615.1@sss.pgh.pa.us> Date: Wed, 03 Jul 2019 15:20:15 -0400 Message-ID: <2305.1562181615@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk David Rowley writes: > I also did some more benchmarking of the patch. ... > Which makes the patched version 2.2% faster than master on that run. BTW, further on the subject of performance --- I'm aware of at least these topics for follow-on patches: * Fix places that are maintaining arrays parallel to Lists for access-speed reasons (at least simple_rte_array, append_rel_array, es_range_table_array). * Look at places using lcons/list_delete_first to maintain FIFO lists. The patch makes these O(N^2) for long lists. If we can reverse the list order and use lappend/list_truncate instead, it'd be better. Possibly in some places the list ordering is critical enough to make this impractical, but I suspect it's an easy win in most. * Rationalize places that are using combinations of list_copy and list_concat, probably by inventing an additional list-concatenation primitive that modifies neither input. * Adjust API for list_qsort(), as discussed, to save indirections and avoid constructing an intermediate pointer array. I also seem to recall one place in the planner that's avoiding using list_qsort by manually flattening a list into an array, qsort'ing, and rebuilding the list :-( I don't think that any one of these fixes would move the needle very much on "typical" simple workloads, but it's reasonable to hope that in aggregate they'd make for a noticeable improvement. In the meantime, I'm gratified that the initial patch at least doesn't seem to have lost any ground. regards, tom lane