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 1hB4YL-0001Cm-F5 for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Apr 2019 21:33:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hB4YJ-0006Do-S4 for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Apr 2019 21:33:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hB4YJ-0006Cz-D9 for pgsql-hackers@lists.postgresql.org; Mon, 01 Apr 2019 21:33:11 +0000 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hB4YG-0006Ja-2q for pgsql-hackers@lists.postgresql.org; Mon, 01 Apr 2019 21:33:09 +0000 Received: by mail-qt1-x844.google.com with SMTP id w5so12527445qtb.11 for ; Mon, 01 Apr 2019 14:33:07 -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:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=TN270+iTyIYWGFSRIXhBI/UROCPAmnZldIltHw8iwhQ=; b=mQBRxgPnZJzvc4O87NUHhsE7q1VpSl6zAiyvEvtDb7gpc45JLXUjCSrsBEdwLHBOQr i+/nPMvdpkBGFGCbywVYmOE3FYDLgImceglsydzz7j/6c23yTgMuSfx2iDcd+gV5fJR7 XMYbAcAIx+qIp909Z5V36fGCvoLXFLXsh92b4zNoKny1TvxpqKHaDYFuNdq4kmPj4dRo O+9kTrP6lDUcFl3Dx4Nct4vOiUjV0s3KzY+qSyVajZr80S1a96ZuGutmo27XeNICACYX yBMbQMVHRmkqdeAElt1IkiHpw+tmdskJY9pvLv+SLfEtJBRZt4dy+btXDQ+dFl7wJDK2 2HoQ== 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:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=TN270+iTyIYWGFSRIXhBI/UROCPAmnZldIltHw8iwhQ=; b=KBpUHzO6drwets/1N1GD1xS5WgkfBXodAlKg0vKa0YWQ2pzPcd3KLmHLZVXyWk4kyL OawjSY2SPpOSowrwuAkAmY78N3iLlGDaLttaM9UlqNsFWgFhPGJHD10LpK3BczHIzj+X DYTG00RPiWEk33/zYUNneylGYCR/D6MJcSqSI6BeLZe5MRUjuv2TRyvWx0UAk/UJJRnB ybRb4dkH/YwAajzUk0vSxkVgU7YZDb6hYNoXVf+B94d3ULFcvJsybsjJTv0mqhGm48rh 5ABVwz5fSv3jG9lPR7zmuGrXCPzHSGp301HKQlrH4RTQNyox3YpMYPzQH+jdd/APUa+6 SYXQ== X-Gm-Message-State: APjAAAW5bFDrYIWJCvQ66hvkHd2gKWN3F8Kw4XMWDgKVvzIUihDzAvT7 8r4R72WDFqjpI3vU4Q04vhNRFg== X-Google-Smtp-Source: APXvYqzpvsw7lirajXZYMSQXpZU0WOC0B47MPOLnfPxAlEmY58pgnCj2Fe96iAShrEDPLT5vtr4zTg== X-Received: by 2002:a0c:9dc1:: with SMTP id p1mr30398929qvf.60.1554154386324; Mon, 01 Apr 2019 14:33:06 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id p27sm3848156qte.25.2019.04.01.14.33.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Apr 2019 14:33:05 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 82B821210F5; Mon, 1 Apr 2019 18:33:03 -0300 (-03) Date: Mon, 1 Apr 2019 18:33:03 -0300 From: Alvaro Herrera To: Rahila Syed Cc: Andres Freund , Robert Haas , Simon Riggs , Pg Hackers , David Fetter , Pavan Deolasee , Amit Langote Subject: Re: monitoring CREATE INDEX [CONCURRENTLY] Message-ID: <20190401213303.GA26854@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Apr-02, Rahila Syed wrote: > 1. FWIW, below results for CIC show that blocks_done does not become equal > to blocks_total at the end of the phase or it processes last 800 blocks so > fast that > the update is not visible in less than 1 secs interval. Yeah, I noticed this too and decided it's not fixable, nor it's desirable to spend a lot of effort in getting it perfectly accurate -- I mean, we could introduce locking or sleeping to get the results we want, but do we really want to make the index building process slower just to report those block numbers. Anyway, I think this effect is caused by parallel btree building: those final blocks are scanned by a worker process, and the leader didn't get the latest block number scanned. If you set max_parallel_maintenance_workers to 0, the effect disappears. (I used \watch 0.01 to see even faster progress updates; even in that case the final batch of block numbers is not seen in the updates. The btree build code is stupidly fast.) > 2. However in case of partitioned tables, the following difference in > blocks_done versus blocks_total at the end of phase is notably high for the > first partition . Subsequent partitions show negligible difference. > Partition 1: > Mon Mar 25 14:27:57 IST 2019 > pid | datid | datname | relid | phase | > lockers_total | lockers_done | current_locker_pid | blocks_total | > blocks_done | tuples_total | tuples_done | partitions_total | > partitions_done > -------+-------+----------+-------+----------------------------+---------------+--------------+--------------------+--------------+-------------+--------------+-------------+------------------+----------------- > 10630 | 13533 | postgres | 16394 | building index: table scan > | 0 | 0 | 0 | 381342 | > 221233 | 0 | 0 | 3 | 0 > (1 row) Hmm, in my tests with partitioned tables, I never noticed such a large discrepancy. I'm going to have another look. 800 blocks scanned by workers I can believe, but 160000 sounds a bit too much. > 3. Sorry for nitpicking, I think following phase name can be made more > consistent with the others. > The non-am specific phase for scanning a table is named as scan heap while > am-specific one is named as table scan. > Can we use heap for am-specific one as well since heap is used elsewhere in > progress reporting too? Hmm, I'd rather go the other way and use "table" everywhere rather than heap, since we've been getting a lot of stuff done for table AMs. > 4. - scan = table_beginscan_parallel(btspool->heap, > ParallelTableScanFromBTShared(btshared)); > + scan = table_beginscan_parallel(btspool->heap, > + > ParallelTableScanFromBTShared(btshared)); > > Is this change required? Yes, for my OCD. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services