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 1vIDfe-0005O4-Gy for pgsql-hackers@arkaria.postgresql.org; Sun, 09 Nov 2025 22:14:02 +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 1vIDfc-00AGgC-1F for pgsql-hackers@arkaria.postgresql.org; Sun, 09 Nov 2025 22:14:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vIDfb-00AGcy-Hj for pgsql-hackers@lists.postgresql.org; Sun, 09 Nov 2025 22:13:59 +0000 Received: from mail-yw1-x1134.google.com ([2607:f8b0:4864:20::1134]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vIDfY-006s2m-28 for pgsql-hackers@lists.postgresql.org; Sun, 09 Nov 2025 22:13:58 +0000 Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-786635a8ce4so19005267b3.2 for ; Sun, 09 Nov 2025 14:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xzilla-net.20230601.gappssmtp.com; s=20230601; t=1762726434; x=1763331234; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+CmkdWcmVzLYoBGT3rfPjWrljHUtmFrgBdJfPrVYc2k=; b=qoIVSHn7WKrpuTg/usbaXbJzvxqV/9OehkRKxStCA4dhagKDYXp9yhglEJ4Zrrk/uQ 73lQUGZ+J/xzbNljatVw2nPOt6cKhfZzvSZo0UpDhPL2O4hv4Y353Zj0kYQY5Df04hoI CtLwzONU07WEHC8M6NJ0vDXdAeQaO4lJTSx6igcN24L9OSWDEP+MGuNxkQYVi6vAjjvh LtYcGJPJMHoXeB2aqFoKLBAAFt75zDzxbYbaT2SMmf62H0lD2VpyIsxAgEgDRisxMLH2 CB2W0pApPXejCfqE71J+GRHsxdshw2iK1SMy7NlEnif7meHt6xT97BokMG14SWcCPu4F oZEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762726434; x=1763331234; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+CmkdWcmVzLYoBGT3rfPjWrljHUtmFrgBdJfPrVYc2k=; b=WjLGwjjat2Bql5iVh26ArqzFRL79eFdEM2rpur3Ye1kK5YMkGyaU1sZfyg0Toe8UCr 4M4fDGq1YQM+V+O/zv+oiB8oyvfoxFfYzjScbXCbWsJqCX/PWomB1vocQlN42IajzJAT ERkrISBUMwoUt/rAaup7ZbJ9rq/e/5XDH+KvzCoww/eyewTyAjIwC1GlOI0mebeV2ZF4 H7P/1yVLDOBb93acW0VlFIKtM9n1xXi7VKDoNIiUzQfmga7cTPAxMwJrHQJ5g95ihSs0 5DQjyVmeyvVAflAwDVMa+tdNFpotBBnZl8i3wboLAFLYFjyNSw2uOKHl5oqUoMeuVAgs pWYQ== X-Forwarded-Encrypted: i=1; AJvYcCUPrLY9R3awNg7nr7qvBFIJdzhvB4uoBO7ixDCK6PDXO+8AVwCoN/Ym2CFPheJeibYKkToNOLS/sPNiUv9i@lists.postgresql.org X-Gm-Message-State: AOJu0YyY+bgct1lc9zYoA3G8zgpHekejehkeDvu9bWJQvUN9mkG7DlgW ji4NKJvYLBtb5J3euDUcArgTnECvIhLV6GTTUIUv7OjSp1K69FacnAqTkUf6ifGI1BgEg5PRQzV KKv7GpqbenGqktynbNdqA71lSNeGsqvoJcWnBrv+SlQ== X-Gm-Gg: ASbGncvPD9ZT5dLtmZxfvfjjmeC4Ky6Z6hZvaCAYtDtvb7CXj5ucGIJfF/LtujmysMq b9s+7LpwL0wSrVPsziwVezHSJI0wQ8jXWYGMRUmlIoa1O+PNAEX4f8yRqBxrdmMi40T4SOIb6+a yp3fzdBlnLcpxTNHHGGRosZhcIuFU4J38asEKnXVkga6TaQwgYe3ckhxRkISPrSu9AhzJtJ8/A9 ZBHdSmKI+9sEh4hmyNf+N8Me6J8fBnJ09SaXUCIOHc0tFBWjS9WvYMo3ZdP X-Google-Smtp-Source: AGHT+IGtVBkoto7L2Pso5JStYNKuPU+7ugm73ivomKeTMve2E7OeZJ8Y+/ffEnBSbNmR+iHnw6EqpaKdGLs7DUBJH+Y= X-Received: by 2002:a05:690c:992:b0:787:d1e7:e75b with SMTP id 00721157ae682-787d5472997mr36772997b3.64.1762726434599; Sun, 09 Nov 2025 14:13:54 -0800 (PST) MIME-Version: 1.0 References: <202507262156.sb455angijk6@alvherre.pgsql> <202510301734.pj4uds3mqxx4@alvherre.pgsql> <7224.1762326739@localhost> In-Reply-To: <7224.1762326739@localhost> From: Robert Treat Date: Sun, 9 Nov 2025 17:13:43 -0500 X-Gm-Features: AWmQ_bnavgdVEpIjAB-X9rRD0JIio9eqz_iwrgCq993d8ATyobiZ6RIwvrmplsc Message-ID: Subject: Re: Adding REPACK [concurrently] To: Antonin Houska Cc: jian he , Alvaro Herrera , Pg Hackers , Mihail Nikalayeu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Nov 5, 2025 at 2:12=E2=80=AFAM Antonin Houska wrot= e: > Robert Treat wrote: > > On Tue, Nov 4, 2025 at 9:48=E2=80=AFPM jian he wrote: > > > > what the expectation of > > > pg_repackdb --index=3Dindex_name, the doc is not very helpful. > > > > > > pg_repackdb --analyze --index=3Dzz --verbose > > > pg_repackdb: repacking database "src3" > > > pg_repackdb: error: processing of database "src3" failed: ERROR: "zz= " > > > is not an index for table "tenk1" > > > > > > select pg_get_indexdef ('zz'::regclass); > > > pg_get_indexdef > > > --------------------------------------------------- > > > CREATE INDEX zz ON public.tenk2 USING btree (two) > > > > > > > Hmm... yes, this is a bit confusing. I didn't verify it in the code, > > but from memory I think the --index option is meant to be used only in > > conjunction with --table, in which case it would repack the table > > using the specified index. I could be overlooking something though. > > The corresponding code is: > > + /* > + * In REPACK mode, if the 'using_index' option was given but no i= ndex > + * name, filter only tables that have an index with indisclustere= d set. > + * (If an index name is given, we trust the user to pass a reason= able list > + * of tables.) > + * > + * XXX it may be worth printing an error if an index name is give= n with no > + * list of tables. > + */ > + if (vacopts->mode =3D=3D MODE_REPACK && > + vacopts->using_index && !vacopts->indexname) > + { > + appendPQExpBufferStr(&catalog_query, > + " AND EXISTS (SE= LECT 1 FROM pg_catalog.pg_index\n" > + " WHERE indre= lid =3D c.oid AND indisclustered)\n"); > + } > > I'm not sure if it's worth allowing the --index option to have an > argument. Since the user can specify multiple tables, he should also be a= ble > to specify multiple indexes. And then the question would be: what should > happen if the user forgot to specify (or just mistyped) the index name fo= r a > table which does not yet have the clustering index set? Skip that table (= and > print out a warning)? Or consider it an error? > Ah, yes, this is something completely different. So, we do need a way to differentiate between "vacuum full" vs "cluster" all tables... as well as "vacuum full" vs "cluster" of a specific table (including the idea of "vacuum full" of a previously clustered table, and the existing code handles all that (though I might quibble with the option name). As for having an --index=3D option, I'd love to hear the use case; something like partitions or maybe some client per schema situation comes to mind, but ISTM in all those cases the user would also know (or be expected to know) the table name, so I agree with Antonin that the extra complexity doesn't seem worth supporting to me. (It's even worse the more you think about it, what if some table has the index named above, but is clustered on a different index, then what should we do?) As for the use case I was thinking of, specifying a table and index in order to repack using that index (and setting indisclustered if not already); while I feel like that would be a useful option, if it isn't currently supported I don't see a strong argument for adding it now. Robert Treat https://xzilla.net