Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jItT3-0005Mu-2C for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2020 12:24:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jItT1-00021z-I0 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2020 12:24:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jItT1-00021s-60 for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2020 12:24:35 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jItSx-0005KK-Ue for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2020 12:24:33 +0000 Received: by mail-wm1-x342.google.com with SMTP id f6so15063899wmj.3 for ; Mon, 30 Mar 2020 05:24:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=k7hUHmhZl5LaHLob8+PEcWnY/ImEwn5FXIuyIY19zbI=; b=Bj+HiMMJ3+VBzS9g/89qZ2tvr3dGgVTDK+yLJLFnITNPGiJoQl9VWX3wPwvfdb+Pxs Vih1QDdEEGqWREvLb4G6pOd9BJQtTwlnwUEw4Ux048LOfGl3EEdEz5cyhXJi7ZTHVoD0 N8mT1acdNlMptRF4BDYKHexFTPtY8gqcB9riESa5+vJ3GZTSpaImEqWQtsqUAW51LU3c 2ob9yN2zjjEeH3zcBwy+dJ0kiBeFbBTc3FB6dvmcHNFin93T0Yl4+t0vwwTg6gpzA5Vh wtJpXeUtHo5nnOnID4yei0SO6mqWsZefeZXVf9kBdz9I/TeIu8we6Kp3AMjM9g0WA++7 nK6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=k7hUHmhZl5LaHLob8+PEcWnY/ImEwn5FXIuyIY19zbI=; b=r9TTcH4rWYDfCWQROBkm/fnQZSzFw2yMEswPhN/n6t4yOlstFHPP2OAqWqx0b70SGR oRgycwI1dkHYLcmV8TroJFy8VrA9OLJL8CCCNka4RCJ0+10VQb4wfucS39GJxhc/iJJ5 W3JjFyZ4wkMYC4jl+E1TsGaS/n8J2CH2QfXzxnjp/qJrDUR0JtO28Ks55sHlNS1mnaot QybQ5btOOi/Nx23UiEJdPokJguxBy1R59llurfCEWQ6xFfxr64ZIIAtRx+C8/B5azpaN /QITazFKCdUYkHT6fyXswcWsTVcWK21Vz8zIBdOZXl9hV6FVge3Uw0M/8CA5aGykyba4 PVRw== X-Gm-Message-State: ANhLgQ0y8lYvnKLYvzPqI4ygWwQa6GoPBqbFdTohVvHnkmoI1jkdJ31E D/NXogZW8q0TXUEtb7Byx3eTjg== X-Google-Smtp-Source: ADFU+vtBSdyNVfaNxK1on8YmH04T7OB4zTxcqabUg0sZ/ST68YX2/1uNnChoK1W+zwebynDJI+xJfg== X-Received: by 2002:a7b:c2a1:: with SMTP id c1mr11193982wmk.138.1585571070436; Mon, 30 Mar 2020 05:24:30 -0700 (PDT) Received: from localhost (ip-86-49-253-141.net.upcbroadband.cz. [86.49.253.141]) by smtp.gmail.com with ESMTPSA id q8sm23112214wrc.8.2020.03.30.05.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2020 05:24:29 -0700 (PDT) Date: Mon, 30 Mar 2020 14:24:26 +0200 From: Tomas Vondra To: James Coleman Cc: Alvaro Herrera , Michael Paquier , Rafia Sabih , Peter Geoghegan , Simon Riggs , Shaun Thomas , Dmitry Dolgov <9erthalion6@gmail.com>, Alexander Korotkov , Tom Lane , PostgreSQL Developers , Andreas Karlsson Subject: Re: [PATCH] Incremental sort (was: PoC: Partial sort) Message-ID: <20200330122426.wjdfpqiatv4ybui7@development> References: <20200328025830.6v6ogkseohakc32q@development> <20200328213050.byyeuozylnxv2bhf@development> <20200328225922.ljnw54bfg44vi6ib@development> <20200329031437.yvhogo25wdijwpqd@development> <20200330014442.chqnwfmelm3ejsgr@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, Mar 29, 2020 at 10:16:53PM -0400, James Coleman wrote: >On Sun, Mar 29, 2020 at 9:44 PM Tomas Vondra > wrote: >> >> Hi, >> >> Attached is a slightly reorganized patch series. I've merged the fixes >> into the appropriate matches, and I've also combined the two patches >> adding incremental sort paths to additional places in planner. >> >> A couple more comments: >> >> >> 1) I think the GUC documentation in src/sgml/config.sgml is a bit too >> detailed, compared to the other enable_* GUCs. I wonder if there's a >> better place where to move the details. What about adding some examples >> and explanation to perform.sgml? > >I'll take a look at that and include in a patch series tomorrow. > >> 2) Looking at the explain output, the verbose mode looks like this: >> >> test=# explain (verbose, analyze) select a from t order by a, b, c; >> QUERY PLAN >> -------------------------------------------------------------------------------------------------------------------------------------------------------------- >> Gather Merge (cost=66.31..816072.71 rows=8333226 width=24) (actual time=4.787..20092.555 rows=10000000 loops=1) >> Output: a, b, c >> Workers Planned: 2 >> Workers Launched: 2 >> -> Incremental Sort (cost=66.28..729200.36 rows=4166613 width=24) (actual time=1.308..14021.575 rows=3333333 loops=3) >> Output: a, b, c >> Sort Key: t.a, t.b, t.c >> Presorted Key: t.a, t.b >> Full-sort Groups: 4169 Sort Method: quicksort Memory: avg=30kB peak=30kB >> Presorted Groups: 4144 Sort Method: quicksort Memory: avg=128kB peak=138kB >> Worker 0: actual time=0.766..16122.368 rows=3841573 loops=1 >> Full-sort Groups: 6871 Sort Method: quicksort Memory: avg=30kB peak=30kB >> Presorted Groups: 6823 Sort Method: quicksort Memory: avg=132kB peak=141kB >> Worker 1: actual time=1.986..16189.831 rows=3845490 loops=1 >> Full-sort Groups: 6874 Sort Method: quicksort Memory: avg=30kB peak=30kB >> Presorted Groups: 6847 Sort Method: quicksort Memory: avg=130kB peak=139kB >> -> Parallel Index Scan using t_a_b_idx on public.t (cost=0.43..382365.92 rows=4166613 width=24) (actual time=0.040..9808.449 rows=3333333 loops=3) >> Output: a, b, c >> Worker 0: actual time=0.048..11275.178 rows=3841573 loops=1 >> Worker 1: actual time=0.041..11314.133 rows=3845490 loops=1 >> Planning Time: 0.166 ms >> Execution Time: 25135.029 ms >> (22 rows) >> >> There seems to be missing indentation for the first line of worker info. > >Working on that too. > >> I'm still not quite convinced we should be printing two lines - I know >> you mentioned the lines might be too long, but see how long the other >> lines may get ... > >All right, I give in :) > >Do you think non-workers (both the leader and non-parallel plans) >should also move to one line? > I think we should use the same formatting for both cases, so yes. FWIW I forgot to mention I tweaked the INSTRUMENT_SORT_GROUP macro a bit, by moving the if condition in it. That makes the calls easier. >> 3) I see the new nodes (plan state, ...) have "presortedCols" which does >> not indicate it's a "number of". I think we usually prefix names of such >> fields "n" or "num". What about "nPresortedCols"? (Nitpicking, I know.) > >I can fix this too. > >Also I noticed a few compiler warnings I'll fixup in tomorrow's reply. > OK regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services