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.96) (envelope-from ) id 1vOg0X-000qUi-0x for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Nov 2025 17:42:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vOfzW-007dP6-2G for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Nov 2025 17:41:15 +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.96) (envelope-from ) id 1vOfzW-007dOy-1H for pgsql-hackers@lists.postgresql.org; Thu, 27 Nov 2025 17:41:14 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vOfzU-001mZQ-0m for pgsql-hackers@postgresql.org; Thu, 27 Nov 2025 17:41:13 +0000 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-5958187fa55so908151e87.3 for ; Thu, 27 Nov 2025 09:41:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764265271; x=1764870071; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=pinJNc05orYWEIziWQApqIOQAg8N4V0FM0EBtBOeNk8=; b=KXj9GHAoNXMhrfVPpi+YC3W4WwXt+iwoyMkFW2XrxfZw5fl2W4ZcPqHmfMaWm4Tkxl Q3yVpt/pBiZZK7bOIuhyfv16WotCyxGGCeVkfjUbUG2vy1pKlVW0iB547HsYgcVtL0Bt qJfKgvcbUttaJal04uKiJWOWFfqh2PtXiraQ2lP2kh9bzRG45imoMNK89q+T2cW3G2yR 4TCxxY195XfOv6SFrz88EP4FuVMbcl4p+Kos+yPAAl86joNKJvpQx9MttiG7Tc8kqZ8Q SPND00S1hMxvunqLekukEbuuZQduhzFdwd8xVLgp5rUO604iQaJ16X/e6jpy9OvEgLXZ X2Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764265271; x=1764870071; h=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=pinJNc05orYWEIziWQApqIOQAg8N4V0FM0EBtBOeNk8=; b=wZKE4s/RyMrU7H82nLFdeNlQqhFUoBgjtOiEz1gztpvdjDpQdiPpFumpL0nIkwgvAN W8pa33e325uO1J4c5MA/+DpXpcuLvGfTx3GJYo2/ODbRjkBHifdHOLBXFi6DqwsawYOs wUO1PsHXXDbn8w7SkvZkXOrGb8v4Q65XmOa+24a1VyDlm4Xax1jV/jHa9dGtR7ffiLYz 4Cd8szZDP8eTHWLYKc8rIbbpDIM57ePogjW/law6dkQxNJOLA6nWeFNrpxkn3dcnXxC/ JC6g4zQ9hCXOL8wlqnLP4gsKauwgmlZ8aEisKTgBiOgeUD7rQp6xwoCeaTwfheNmZH9j NC5Q== X-Gm-Message-State: AOJu0Yyqhw/OBPeE1pzm0uXTQKCxDRW2p2lS7VoPAJoOINeIFud7MAAX AGnVtNm4PTBJgorYauLGJauqSXjpzNLxB2NyHcr2oONHExw2XilsBOyBRINs/avjNEjezKcLayG 9oAxy42e2Eh9NZVEDiCgWEX9xh8yXM+sbh/NR X-Gm-Gg: ASbGncuO/BaeCnfPbJiX+NJnyuufIzmldYuiDYc+bJ/HutXf020ipPgGkxgFh6vfxRB Sa6Cy/tyjXSlymJtYeb+FV+NzuZV3m9cXiu8kOOzHtiUWQDBbwyGc0kYwrHTKAqfwvDTB/0+MyH XGGVVDopLuSyNPFeYcxbHkw83uy2pKO6dgXqoX8ZVYHCBqUJ70KCWNT+kgoXk/etriIYt4axDH4 KOvY4+BwMnUvoH9PULhg9i/NuWKn2XxnK4knZuA6qyiFSfXW6iw2LBiIv9ZMr84MBD6ftQ= X-Google-Smtp-Source: AGHT+IFmlqOsAN9w6suVEcOrh4bhIWTmzDqkDYNJ6YqT/YLXVis4Pn+kD7k+wYAtIbKSHYQHrJK4hyLkERMrUlvG9vU= X-Received: by 2002:a05:6512:ac4:b0:594:5236:282d with SMTP id 2adb3069b0e04-596b4e4b778mr4528237e87.4.1764265271049; Thu, 27 Nov 2025 09:41:11 -0800 (PST) MIME-Version: 1.0 References: <17483.1764262585@localhost> In-Reply-To: <17483.1764262585@localhost> From: Mihail Nikalayeu Date: Thu, 27 Nov 2025 18:40:34 +0100 X-Gm-Features: AWmQ_bn3X1mSs8RS3_AOc_jeTkLREFCLiFutbqx3CM4wnHNmhbNCThP6U6qU634 Message-ID: Subject: Re: Revisiting {CREATE INDEX, REINDEX} CONCURRENTLY improvements To: Antonin Houska Cc: PostgreSQL Hackers , Alvaro Herrera Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, Antonin! > I haven't read the whole thread yet, but the effort to minimize the impact of > C/RIC on VACUUM seems to prevail Yes, the thread is super long and probably you missed annotations to most important emails in [0]. > Of course, I could have missed some important point, so please explain why > this concept is broken :-) Or let me know if something needs to be explained > more in detail. Thanks. Looks like your idea is not broken, but... It is actually an almost 1-1 to idea used in the "full" version of the patch. Explanations are available in [1] and [2]. In [3] I reduced the patch scope to find a solution compatible with REPACK. Few comments: > 1. Create an empty index. Yes, patch does exactly the same, introducing special lightweight AM - STIR (Short Term Index Replacement) to collect new tuples. > 4.1 Acquire (shared) content lock on the buffer. > 4.3 Collect the root tuples of HOT chains - these and only these need to be inserted into the index. > 4.4 Unlock the buffer. Instead of such technique essentially the same is used - it keeps the snapshot to be used, it just rotates it every few pages for a fresh one. It solves some of the issues with selection of alive tuples you mentioned without any additional logic. > Concurrent (re)build of unique index appears to be another topic of this > thread, but I think this approach should handle the problem too. It is solved with a special commit in the original patchset. You know, clever people think the same :) Interesting fact, it is not the first time - at [4] Sergey also proposed an idea of an "empty" index to collect tuples (which gives the single scan). So, it is very good knews the approach feels valid for multiple people (also Mathias introduced the idea about "fresh snapshot"~"no snapshot" initially). One thing I am not happy about - it is not applicable to the REPACK case. Best regards, Mikhail. [0]: https://commitfest.postgresql.org/patch/4971/ [1]: https://www.postgresql.org/message-id/CADzfLwVOcZ9mg8gOG+KXWurt=MHRcqNv3XSECYoXyM3ENrxyfQ@mail.gmail.com [2]: https://www.postgresql.org/message-id/CADzfLwW9QczZW-E=McxcjUv0e5VMDctQNETbgao0K-SimVhFPA@mail.gmail.com [3]: https://www.postgresql.org/message-id/CADzfLwVaV15R2rUNZmKqLKweiN3SnUBg=6_qGE_ERb7cdQUD8g@mail.gmail.com [4]: https://www.postgresql.org/message-id/flat/CAMAof6_FY0MrNJOuBrqvQqJKiwskFvjRtgpVHf-D7A%3DKvTtYXg%40mail.gmail.com