Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kYkQD-00032F-OG for pgsql-hackers@arkaria.postgresql.org; Sat, 31 Oct 2020 06:31:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kYkQA-0004i6-Ui for pgsql-hackers@arkaria.postgresql.org; Sat, 31 Oct 2020 06:31:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kYkQA-0004hz-Gp for pgsql-hackers@lists.postgresql.org; Sat, 31 Oct 2020 06:31:26 +0000 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kYkQ5-0001YX-UI for pgsql-hackers@lists.postgresql.org; Sat, 31 Oct 2020 06:31:25 +0000 Received: by mail-il1-x133.google.com with SMTP id q1so8418719ilt.6 for ; Fri, 30 Oct 2020 23:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:user-agent; bh=hUldIapHh95/x1iJUhL9BHWoQ+t/vHiidxwIyKHgzao=; b=jNulssVhtrceKc8M6dvBM1MkNV5VhvodOHrmanidX+grX0gEOuX5ObU3YUe4vVstwD lpuF0gNW07NMJR2pRSS7uz6OSJkTnyqKovFgiyTSDNhoaerbVu8qCPUsmLei98Suia2V MNpsxEAoOxIqKk75ArDdYUeE8Bb67ZOma5byQcsV911ZqC2jOZT3jDAfFjdXdJRRlQKL 8iQRmRZUHU6FLb3xnsqhXWFMQ5bAVW6zJ5genD3G8Kj8yCUupQJsJK7rfjTZbIsU0emy 79AWaMHVK5X/fmFL2y0q5bwBH/8TAx5twqFZqnRuajVJvWeUwjuy3FG0QY3CJeKFqd5Q PW5w== 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:user-agent; bh=hUldIapHh95/x1iJUhL9BHWoQ+t/vHiidxwIyKHgzao=; b=bx8h1De7TXksrsvicUEfmfUqo5OOAGub92DqCJTs/kvEMz7z4SDDexUtQCUGvpsIdG VFpLbKaD2fswDL8MdhDRBNFkmBs7JpRK25jWjxIL2dSG5Ka0tHs2F0x4H6EPNdKCKePW fvtS7DJgDIJxZ84U+8GS97a22MRact9Bdhr5kvRQevcYBy8gkh2l7OW9VWVbT9SArdZJ P9plWjHH34IWS+iQSclI62dAEr9qjhjDwuv38DaeOfi8rYJGcJuocMo3capNgiEJCuGz ZixgqLsjg7j6EOiVrYq23fX51a974oFchUsZhN2sbstVAhEjFhVvTggxp/FqUzz1B7tj YOig== X-Gm-Message-State: AOAM531Bb7bZQpSdAG/Omnf5SpTSc2mMqY9IHUE/hK31DVS5UPhtLPIp xHOWTP2jdBfvhy5rHh0+v/yc5g== X-Google-Smtp-Source: ABdhPJxtb3FNwnAxPUeiLa3N7stRmz/Sm3sEdcskYAPWqREnd9NLH7M/jcezqRgWvHiBfO8OdkSFsw== X-Received: by 2002:a92:aa8b:: with SMTP id p11mr525833ill.5.1604125880033; Fri, 30 Oct 2020 23:31:20 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id e4sm5993853ils.75.2020.10.30.23.31.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Oct 2020 23:31:18 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 97F17800665; Sat, 31 Oct 2020 01:31:17 -0500 (CDT) Date: Sat, 31 Oct 2020 01:31:17 -0500 From: Justin Pryzby To: Michael Paquier Cc: =?utf-8?B?5p2O5p2wKOaFjui/vSk=?= , pgsql-hackers , =?utf-8?B?5pu+5paH5peMKOS5ieS7jik=?= , Alvaro Herrera Subject: CREATE INDEX CONCURRENTLY on partitioned index Message-ID: <20201031063117.GF3080@telsasoft.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="i3lJ51RuaGWuFYNw" Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --i3lJ51RuaGWuFYNw Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Forking this thread, since the existing CFs have been closed. https://www.postgresql.org/message-id/flat/20200914143102.GX18552%40telsasoft.com#58b1056488451f8594b0f0ba40996afd The strategy is to create catalog entries for all tables with indisvalid=false, and then process them like REINDEX CONCURRENTLY. If it's interrupted, it leaves INVALID indexes, which can be cleaned up with DROP or REINDEX, same as CIC on a plain table. On Sat, Aug 08, 2020 at 01:37:44AM -0500, Justin Pryzby wrote: > On Mon, Jun 15, 2020 at 09:37:42PM +0900, Michael Paquier wrote: > > On Mon, Jun 15, 2020 at 08:15:05PM +0800, 李杰(慎追) wrote: > > > As shown above, an error occurred while creating an index in the second partition. > > > It can be clearly seen that the index of the partitioned table is invalid > > > and the index of the first partition is normal, the second partition is invalid, > > > and the Third Partition index does not exist at all. > > > > That's a problem. I really think that we should make the steps of the > > concurrent operation consistent across all relations, meaning that all > > the indexes should be created as invalid for all the parts of the > > partition tree, including partitioned tables as well as their > > partitions, in the same transaction. Then a second new transaction > > gets used for the index build, followed by a third one for the > > validation that switches the indexes to become valid. > > Note that the mentioned problem wasn't serious: there was missing index on > child table, therefor the parent index was invalid, as intended. However I > agree that it's not nice that the command can fail so easily and leave behind > some indexes created successfully and some failed some not created at all. > > But I took your advice initially creating invalid inds. ... > That gave me the idea to layer CIC on top of Reindex, since I think it does > exactly what's needed. On Sat, Sep 26, 2020 at 02:56:55PM -0500, Justin Pryzby wrote: > On Thu, Sep 24, 2020 at 05:11:03PM +0900, Michael Paquier wrote: > > It would be good also to check if > > we have a partition index tree that maps partially with a partition > > table tree (aka no all table partitions have a partition index), where > > these don't get clustered because there is no index to work on. > > This should not happen, since a incomplete partitioned index is "invalid". -- Justin --i3lJ51RuaGWuFYNw Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v10-0001-Allow-CREATE-INDEX-CONCURRENTLY-on-partitioned-t.patch"