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 1pHrsy-000134-AE for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Jan 2023 19:44:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pHrsx-0000Hj-1b for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Jan 2023 19:44:43 +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 1pHrsw-0000Gj-JO for pgsql-hackers@lists.postgresql.org; Tue, 17 Jan 2023 19:44:42 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pHrst-0006gj-Oj for pgsql-hackers@lists.postgresql.org; Tue, 17 Jan 2023 19:44:41 +0000 Received: by mail-wr1-x42b.google.com with SMTP id b7so5746381wrt.3 for ; Tue, 17 Jan 2023 11:44:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=xQtzkWKLqk4JZwEmZaEAZaZkwAsuuaf9oDvAZSXbwS4=; b=h7OYNdOvmzP9uQOboxNEfdvpdVArnIuFlkPgJWIetUrEXeQ+SPTRFSNIhhUFAG3vF5 5F4I1hS9+xkseEOF0dChu3coFL1VKbTWQ9xbSjzsIPw0dCeNPyE4j4FQIs4U1LQDMrNo sqJl5q4S9fvt5XZH2vuOR5fa1xZ7eKiMaDGAuQ1ThSEK340QEK4PXHH9mu/JN3PjXRWf TuLG+eI+Uzw209QEJqddHwBzKfZwF0UyAnw5W2Xy2CUpK7SSnnwHipnO4gia+8lnkFm7 Yc/AieOov7HAdPEBgWSpJp3liu7+L6SyTvkAIPXaMqAzaTWsuX70nQHn/NmeYK8mIt0g mbgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xQtzkWKLqk4JZwEmZaEAZaZkwAsuuaf9oDvAZSXbwS4=; b=3EDBCEz4BsR3FBWlYGmf3e/wEXKoDecGvfmO1HO8niOifmS7iKMLvhKO02yq+MEBmY Bir4hha9C8rVYT49RwQ4v0KzOmRWBEHj4piFZIWw34NIn9fvTI83TZT24HaCZO5lchMk dEAagfCx+gpNax5O/FWwqHHWSin2Uq8kPzBWlvkyUglbxEkb5tJL5PYFQkLFIVqcH4a6 2bEQAB3OByg5voukFqc3kDuaj23m3gxVLmkuTxrxakoveIfU2PujLEYM/pOfICpxzyWB b8Oj/PdO3x9GrgBq8R6b1Af2otcZC+yy8YMetoIvAh5zgwY6zkC9GuWXoq1ZnCYiSxx6 PhcQ== X-Gm-Message-State: AFqh2kq36Th2Qqdub2FIvQk77WZjLPn8M4cMAG4ced5LZjnfZ7mxASwX 1ltmq80gUD/iQXpk4AcmaCKG3z5f1AOVW2uP878L7Divjk0WC4rNUIitm3N4oa4gbG/sToXrRWi XnPYSXz+28+ZP5m6KWbnf4j7HG5Nngd0pK4X5Ir1EsWayhyDINXpbjVQYLYIdImHYc5gOlTVG9J yUDTcMuWfBlwjth7G7T3U6FVWSIKrgPYpskMNXxxp3SKk2XLddp7qo1NHgHhBOCsgbP/gIPh0DQ NDbkvAmuP1nBx7Au8ngn1Wu2pGZgRpXbwgTYB/CWjHDi3D4tffNJUiL/pni X-Google-Smtp-Source: AMrXdXu6nKVHwM27Znt5CFTRL1RYjVdLowgnsiNMgorNNOSILdDIuDv+nUpZErWT3k7BROd3SV6Nyw== X-Received: by 2002:a5d:4ac2:0:b0:2bb:c50f:6381 with SMTP id y2-20020a5d4ac2000000b002bbc50f6381mr3750917wrs.6.1673984678121; Tue, 17 Jan 2023 11:44:38 -0800 (PST) Received: from [10.137.0.17] (static-84-42-175-93.bb.vodafone.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id k7-20020adfd227000000b002bdf3809f59sm8947978wrh.38.2023.01.17.11.44.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Jan 2023 11:44:37 -0800 (PST) Message-ID: <31ee17da-8705-9afc-9451-5374a5e51aff@enterprisedb.com> Date: Tue, 17 Jan 2023 20:44:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: Progress report of CREATE INDEX for nested partitioned tables Content-Language: en-US To: Ilya Gladyshev , Justin Pryzby Cc: pgsql-hackers@lists.postgresql.org References: <039564d234fc3d014c555a7ee98be69a9e724836.camel@gmail.com> <20221217143002.GR1153@telsasoft.com> <20230108164849.GA21731@telsasoft.com> <865a4ff239b6824fd5bbdd4a972390d1e95144b4.camel@gmail.com> From: Tomas Vondra In-Reply-To: <865a4ff239b6824fd5bbdd4a972390d1e95144b4.camel@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/9/23 09:44, Ilya Gladyshev wrote: > On Sun, 2023-01-08 at 10:48 -0600, Justin Pryzby wrote: >> On Sat, Dec 17, 2022 at 08:30:02AM -0600, Justin Pryzby wrote: >>> ... >>> >>> @committers: Is it okay to add nparts_done to IndexStmt ? >> >> Any hint about this ? >> AFAIK fields added at the end of a struct is seen as acceptable from the ABI point of view. It's not risk-free, but we did that multiple times when fixing bugs, IIRC. The primary risk is old extensions (built on older minor version) running on new server, getting confused by new fields (and implied shifts in the structs). But fields at the end should be safe - the extension simply ignores the stuff at the end. The one problem would be arrays of structs, because even a field at the end changes the array stride. But I don't think we do that with IndexStmt ... Of course, if the "old" extension itself allocates the struct and passes it to core code, that might still be an issue, because it'll allocate a smaller struct, and core might see bogus data at the end. On the other hand, new extensions on old server may get confused too, because it may try setting a field that does not exist. So ultimately it's about weighing risks vs. benefits - evaluating whether fixing the issue is actually worth it. The question is if/how many such extensions messing with IndexStmt in this way actually exist. That is, allocate IndexStmt (or array of it). I haven't found any, but maybe some extensions for index or partition management do it? Not sure. But ... Do we actually need the new parts_done field? I mean, we already do track the value - at PROGRESS_CREATEIDX_PARTITIONS_DONE index in the st_progress_param array. Can't we simply read it from there? Then we would not have ABI issues with the new field added to IndexStmt. >> This should be resolved before the "CIC on partitioned tables" patch, >> which I think is otherwise done. > > I suggest that we move on with the IndexStmt patch and see what the > committers have to say about it. I have brushed the patch up a bit, > fixing TODOs and adding docs as per our discussion above. > I did take a look at the patch, so here are my 2c: 1) num_leaf_partitions says it's "excluding foreign tables" but then it uses RELKIND_HAS_STORAGE() which excludes various others relkinds, e.g. partitioned tables etc. Minor, but perhaps a bit confusing. 2) I'd probably say count_leaf_partitions() instead. 3) The new part in DefineIndex counting leaf partitions should have a comment before if (!OidIsValid(parentIndexId)) { ... } 4) It's a bit confusing that one of the branches in DefineIndex just sets stmt->parts_done without calling pgstat_progress_update_param (while the other one does both). AFAICS the call is not needed because we already updated it during the recursive DefineIndex call, but maybe the comment should mention that? As for the earlier discussion about the "correct" behavior for leaf vs. non-leaf partitions and whether to calculate partitions in advance: * I agree it's desirable to count partitions in advance, instead of adding incrementally. The view is meant to provide "overview" of the CREATE INDEX progress, and imagine you get partitions_total partitions_done 10 9 so that you believe you're ~90% done. But then it jumps to the next child and now you get partitions_total partitions_done 20 10 which makes the view a bit useless for it's primary purpose, IMHO. * I don't care very much about leaf vs. non-leaf partitions. If we exclude non-leaf ones, fine with me. But the number of non-leaf ones should be much smaller than leaf ones, and if the partition already has a matching index that distorts the tracking too. Furthermore the partitions may have different size etc. so the progress is only approximate anyway. I wonder if we could improve this to track the size of partitions for total/done? That'd make leaf/non-leaf distinction unnecessary, because non-leaf partitions have size 0. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company