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 1uRG1h-009FWH-2W for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Jun 2025 20:01:53 +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 1uRG1f-003DEA-0E for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Jun 2025 20:01:51 +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 1uRG1e-003DE1-Mw for pgsql-hackers@lists.postgresql.org; Mon, 16 Jun 2025 20:01:51 +0000 Received: from mail-vk1-xa31.google.com ([2607:f8b0:4864:20::a31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uRG1d-002N8r-0r for pgsql-hackers@postgresql.org; Mon, 16 Jun 2025 20:01:50 +0000 Received: by mail-vk1-xa31.google.com with SMTP id 71dfb90a1353d-53164bd0df3so372617e0c.0 for ; Mon, 16 Jun 2025 13:01:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750104108; x=1750708908; darn=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=lz6P2NsxRDq1jwfTxCk8c/xiQvGtd8k+FCgkIxMhaDU=; b=VRNyXJAZpReEqDoebUje+oypZ3BDTuwT1uqZL5zCBTFUatcvLBQCYYwfEZJIpBAcyO 9ff/pmS8KlXIqLe2XtenLTB4Few5uZw8LOgAOnUb756r+YCdV5a1GnGQjSgh1RhSkz0B abnnxxARA8GotfnRuGnbdbJraJi40qWrEPgkly5w5VTMtiPNAzJTgk6nf3Iz/0PChyan I2h3uWSu+KGHpVNr2Mb42HlEtudfnG/Jy7C2+yG+dth3Wau96ozRV+Iy3ZNEH+GfoiVm K8NQHrPuGuTfw9WbSahSBBp13aVtH62JK0VGhrJ6u2aoGFfqW+4Sydwg8X9uIwVFcGBa e8Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750104108; x=1750708908; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lz6P2NsxRDq1jwfTxCk8c/xiQvGtd8k+FCgkIxMhaDU=; b=aJ3VYL+MOMoXyxeuliz7gbLV/y8gPLwMh+vSfylFiIk3Hf3bkepBexa87LsXYzET0w 4eJwCP70gK9zbyvjtxgjrlpIQ2YwPOFYTBcYktJ3JKh9TV5dGr9z5xJ0ggemZ3urWAtS aMt3B4x0VXg6kxCviseGzc/O9OHBfZaJY00UO2QBuSbildGJfgXSrXsQf7TttJ+XfImO T7X72vgPLU+JJu8L8ogJan9GkHpFDs6SLtOLw15pybD7HKZC5uzMFaqAWSYiwn4sudPL odSwVEX30KQqDZgQkLciiLIEtXtbbx96dxImPlsnynv0867t2YtSrRG1hA3ttI+1qODe 8cww== X-Forwarded-Encrypted: i=1; AJvYcCW2GRA5yJILuIzfET5t5I32n6nMVR275SWcBdlKwqFZ9m1DY7rXVkfx0d5KqJn276IjwfPnDAvqztGMbxCm@postgresql.org X-Gm-Message-State: AOJu0YytRoH8lWeDSdNSG8ENaIsBRuqpiGTWIfBXHCEPT+Vqk2TmxFLn jT3emQHwK0SdPxCUcQElCGpLmZW8lVdY9LFSCJprG74MWM2bYfqP7iCB9QyYIOw9M0QbZ2+hxNR af3edvpCODGRGaXSQvF5knUBUoxzqlsA= X-Gm-Gg: ASbGncvA7+4e07AQAyi4xAVWD8VB6DSyb0ONH8OGBh/25Bcb9vIwYuO+QRqBQG5Av3G IUfFoOTTHAxMivdZkeY/bJDjOW+mlA8KXwrBbofPpmbk8aqImStXLSzYuUXEHQ1Ixo9gYHJVsFF FcchZp0AJUOURP9OQeU68sRXiBCQbJ8mq/+uTRC+nQ488= X-Google-Smtp-Source: AGHT+IERDFadTadpqJXYk9htnNE7jx48X6R7q5MuZakn3RVYvJD7AmGO2I3Y7ZmzQUnZbhGzpc+NxCBBlLFEQZM4r0I= X-Received: by 2002:a05:6122:4d02:b0:520:4996:7d2a with SMTP id 71dfb90a1353d-53149c4db68mr6744734e0c.10.1750104108115; Mon, 16 Jun 2025 13:01:48 -0700 (PDT) MIME-Version: 1.0 References: <202505181556.3n6oiowvntyr@alvherre.pgsql> In-Reply-To: From: Mihail Nikalayeu Date: Mon, 16 Jun 2025 22:00:59 +0200 X-Gm-Features: AX0GCFtdeH4nkdyWNuW_5lntNC2AasigvXYVuOyzvpE87zf6fq4jbVHovBNtoqE Message-ID: Subject: Re: Revisiting {CREATE INDEX, REINDEX} CONCURRENTLY improvements To: Sergey Sargsyan Cc: =?UTF-8?Q?=C3=81lvaro_Herrera?= , Andres Freund , Michael Paquier , PostgreSQL Hackers , Andrey Borodin , Melanie Plageman , Matthias van de Meent 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 Hello, Sergey! > I think it's to avoid duplicate errors when adding tuples from STIP to th= e main index, > but couldn't we just suppress that error during validation and skip the n= ew tuple insertion if it already exists? In some cases, it is not possible: =E2=80=93 Some index types (GiST, GIN, BRIN) do not provide an easy way to detect such duplicates. =E2=80=93 When we are building a unique index, we cannot simply skip duplicates, because doing so would also skip the rows that should prevent the unique index from being created (unless we add extra logic for B-tree indexes to compare TIDs as well). > The main index may get huge after building, and iterating over it in a si= ngle thread and then sorting tids can be time consuming. My tests indicate that the overhead is minor compared with the time spent scanning the heap and building the index itself. > At least I guess one can skip it when STIP is empty. Yes, that=E2=80=99s a good idea; I=E2=80=99ll add it later. > p.s. I noticed that `stip.c` has a lot of functions that don't follow the= Postgres coding style of return type on separate line. Hmm... I=E2=80=99ll fix that as well. Best regards, Mikhail.