Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sX5uP-001XJF-3t for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jul 2024 21:21:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sX5uN-001qmj-GE for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jul 2024 21:21:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sX5uM-001qmb-WD for pgsql-hackers@lists.postgresql.org; Thu, 25 Jul 2024 21:21:55 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sX5uK-001R9f-7e for pgsql-hackers@lists.postgresql.org; Thu, 25 Jul 2024 21:21:53 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4279c924ca7so9747305e9.2 for ; Thu, 25 Jul 2024 14:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721942511; x=1722547311; darn=lists.postgresql.org; h=in-reply-to:content-language:references:cc:to:subject:from :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=cwZrbayi1qOldmTqIFNatKyf63Uxyi7kSQaYsvHxWrU=; b=cQTo+N3Nu0NfdAE6+JdAgMpAeGnKcsc9iB5qh7Ws+Dbt26siyVNDOXI/iFa2sbMVdE jHADKaAdisLeffpOUYBP4lJFXOTfgapUi9jMqijusmaMFoiehThbLEcSpK6m3rkrK4qj X9bEiGQ7WCiUJ0h5+0rgcT27a9RnZwCt6bGwgXzNPefmCoJ+9RikWNUjLDNLhxnaGw75 sm5JfqkqryUDIMLeJKxq/cS94kl0bNZuMz/uprf1n5MaY5sAqv6vqjVT3++pErTIZt/K uYsY12kxhTa7iMTdizJpOZkil1b9zS2pf5duTCG/JSnBxvXtC/yyOpgZ81bGYsKbASkH a+9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721942511; x=1722547311; h=in-reply-to:content-language:references:cc:to:subject:from :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=cwZrbayi1qOldmTqIFNatKyf63Uxyi7kSQaYsvHxWrU=; b=oYbpVfdSRBslUvSvmyoP5rAwf/2AP36x5ziVph4vHUNG03jn57PEIxav23jOSY6bD8 jVKdBNnXwsOxC9DYdYi71NG6uwAOGc/DASqxFUzKjtZOnjm7h1j7/bS9+4c1C/b7DKzo FHpfivKbuSTxrhLABX4e4jauaWaBGjKsn9o5Dus/qazct+N6OkSt+yWiAm/AYNCrGu+I 7t0EQi4OJ7z13qOgl7vbunHVEorlCnT0MQ61316GOCdJQPIU+3MKnIGJ+unxzV3glEM/ TdI32oue1RdDmC7C6pEO3S1EG1c9mPQKO+Bkm0pzvZDhaI0eWhYeoOnrItF8dSGjXmYF mwfw== X-Gm-Message-State: AOJu0Yxnsgn6Oa1iHS91hZKRNmKtpv2sVda2pDVx7m135gXc8yq3o7cY V2O3YgA0gp6GHlV3zkz46vqAPuLHcTBLvC5ABOKuHfgzWBg1d5BUPPN+Jw== X-Google-Smtp-Source: AGHT+IHzC662NeflCT1hNAjH4BKc+Zzt67ZewYLz7e5U4oK0Y6s1qVaUWdpXaMJ1VfDNe/V3kEaNBg== X-Received: by 2002:a5d:6484:0:b0:368:310d:c383 with SMTP id ffacd0b85a97d-36b3637ec15mr2802233f8f.5.1721942510326; Thu, 25 Jul 2024 14:21:50 -0700 (PDT) Received: from ?IPV6:2a01:4b00:c00c:a500:378:d9d2:5013:1bd0? ([2a01:4b00:c00c:a500:378:d9d2:5013:1bd0]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367d9859sm3225267f8f.28.2024.07.25.14.21.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Jul 2024 14:21:49 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------74ttM5n8CE0re3hqjnxROLi0" Message-ID: <8f487a28-a559-4fed-bffc-54a92a201fe9@gmail.com> Date: Thu, 25 Jul 2024 22:21:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Ilya Gladyshev Subject: Re: REINDEX not updating partition progress To: Michael Paquier Cc: pgsql-hackers@lists.postgresql.org References: <779baf7f-6fc7-4431-a08e-eec63d84c6a3@gmail.com> <18D00CB1-D34B-4B71-AC65-96F27D69A9D8@gmail.com> Content-Language: en-US In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------74ttM5n8CE0re3hqjnxROLi0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit > 25 июля 2024 г., в 09:55, Michael Paquier > написал(а): > > On Sun, Jul 21, 2024 at 11:41:43AM +0100, Ilya Gladyshev wrote: >> Forgot to update partition_relid in reindex_index in the second >> patch. Fixed in attachment. > >        relid oid >        >        > -       OID of the table on which the index is being created. > +       OID of the table on which the command was run. >        > > Hmm.  I am not sure if we really need to change the definition of this > field, because it can have the same meaning when using a REINDEX on a > partitioned table, pointing to the parent table (the partition) of the > index currently rebuilt. > > Hence, rather than a partition_relid, could a partitioned_relid > reflect better the situation, set only when issuing a REINDEX on a > partitioned relation? I'm not quite happy with the documentation update, but I think the approach for partitioned tables in this patch makes sense. I checked what other commands, that deal with partitions, (CREATE INDEX and ANALYZE) do, and they put a root partitioned table in "relid". ANALYZE has a separate column for the id of partition named current_child_table_relid, so I think it makes sense to have REINDEX do the same. In addition, the current API for progress tracking doesn't have a way of updating "relid" without wiping out all other fields (that's what pgstat_progress_start_command does). This can definitely be changed, but that's another thing that made me not think in this direction. > +   if (relkind == RELKIND_PARTITIONED_INDEX) > +   { > +       heapId = IndexGetRelation(relid, true); > +   } > Shouldn't we report the partitioned index OID rather than its parent > table when running a REINDEX on a partitioned index? > — > Michael It’s used to update the "relid" field of the progress report. It’s the one that’s described in docs currently as "OID of the table on which the index is being created.", so I think it’s correct. --------------74ttM5n8CE0re3hqjnxROLi0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

25 июля 2024 г., в 09:55, Michael Paquier <michael@paquier.xyz> написал(а):

On Sun, Jul 21, 2024 at 11:41:43AM +0100, Ilya Gladyshev wrote:
Forgot to update partition_relid in reindex_index in the second patch. Fixed in attachment.

       <structfield>relid</structfield> <type>oid</type>
      </para>
      <para>
-       OID of the table on which the index is being created.
+       OID of the table on which the command was run.
      </para></entry>

Hmm.  I am not sure if we really need to change the definition of this
field, because it can have the same meaning when using a REINDEX on a
partitioned table, pointing to the parent table (the partition) of the
index currently rebuilt.

Hence, rather than a partition_relid, could a partitioned_relid
reflect better the situation, set only when issuing a REINDEX on a
partitioned relation?

I'm not quite happy with the documentation update, but I think the approach for partitioned tables in this patch makes sense. I checked what other commands, that deal with partitions, (CREATE INDEX and ANALYZE) do, and they put a root partitioned table in "relid". ANALYZE has a separate column for the id of partition named current_child_table_relid, so I think it makes sense to have REINDEX do the same.

In addition, the current API for progress tracking doesn't have a way of updating "relid" without wiping out all other fields (that's what pgstat_progress_start_command does). This can definitely be changed, but that's another thing that made me not think in this direction.

+   if (relkind == RELKIND_PARTITIONED_INDEX)
+   {
+       heapId = IndexGetRelation(relid, true);
+   }
Shouldn't we report the partitioned index OID rather than its parent
table when running a REINDEX on a partitioned index?

Michael

It’s used to update the "relid" field of the progress report. It’s the one that’s described in docs currently as "OID of the table on which the index is being created.", so I think it’s correct.

--------------74ttM5n8CE0re3hqjnxROLi0--