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 1tiKr2-00Efbw-NM for pgsql-general@arkaria.postgresql.org; Wed, 12 Feb 2025 22:05:12 +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 1tiKr0-00FQsF-I2 for pgsql-general@arkaria.postgresql.org; Wed, 12 Feb 2025 22:05:11 +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 1tiKr0-00FQrl-4a for pgsql-general@lists.postgresql.org; Wed, 12 Feb 2025 22:05:10 +0000 Received: from mail-io1-xd44.google.com ([2607:f8b0:4864:20::d44]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tiKqz-000TES-02 for pgsql-general@lists.postgresql.org; Wed, 12 Feb 2025 22:05:09 +0000 Received: by mail-io1-xd44.google.com with SMTP id ca18e2360f4ac-8553e7d9459so6431039f.2 for ; Wed, 12 Feb 2025 14:05:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739397908; x=1740002708; 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=jSGezDoJmglLeutQ+WPGfWd58L5dODVsBWofMFU/5x4=; b=PnWnAxLd2FNjHscsBBBygTwVntAGC/PGtuiP1oU1U/qD65i7LCvV9VS9GhvHWnKB5P nKqZXYCy7bRMsnSKUTFtIvfCcNx8WmwMPeibjunxAzFPUsR6z4mKqG7QCGlate9xa588 TEjOC5Ayi27vbyqgxeJNnoX4F8g5v9gaWu3gNv/1qjQ/JgrGM8xyzgQg9vmeoMXFDec+ mbyBZ9w8x+vo3zHzyUuIO731VcRsb/JgSisjkbVr0tRgA9f2dO0AJ6lSVFJ0h/760H3G 18CUyqbWk1mV4DiOFRK0dBb42KAZPC1qJEUFURA4cNQUkcsWhejOrr9pCOzIhVgBTF8y rS6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739397908; x=1740002708; 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=jSGezDoJmglLeutQ+WPGfWd58L5dODVsBWofMFU/5x4=; b=PoQfYtAY3pfm4+Iadk4h/QGFp9aNHsGF16xSW/TWbBJP4Qto8+iUanGHifT5rSivA8 f6xvgwWHa1YqU9sMNUdiNb/jm0FAjrsDquyrfVfs0+5LA9bvtUEytP6exTAMa1gv17bZ vCHIZyZNfTkezFE+R5g2dNqftaHSdn7r23YUgUf3Lt1IJI4w3Pk1TT4OiExQYHRmDcZZ 9SBaXI2DGps7T/JUJTLWB9CgzXNGePymx97S+J70tFCgutzxlcLJWczvmoUNBbuHRqAc 4bZARPH+sRaEwa6us5UqaP3OoJQw7nGkgDkRIC6jK/gtSke2Y/xXQlewizw5MQdYUr1g yDCA== X-Gm-Message-State: AOJu0YwMFvS3EEMpCz7SbSZMSY/sxKVT+i2tEfHuayt88S04sVdOFmZ8 3cq3brtcZZI6LVPwf4El2wt1Lc+lRvo1PhTVxHDL0m2E6+NfP5//mCEetaXw261QGUCGXgS1sUs CJHK+I+Ztty0TZVYUL5eSPL6dyDM= X-Gm-Gg: ASbGncvMrxMa8mtN2/fJEegR8i/RdEjmg30hMuS1QMY6hLmI2jS4itmBDA4MGdq50fg Gx4HZ2kNlSSAsos2f9XK/n+VPKYQ+sw9f3u0Bk4VRliqNoqNLm4SzIOwgKkjLxg0k+X1o7FbTLw == X-Google-Smtp-Source: AGHT+IHrjwoChIqzrRrkp1oFGNvB1t3xB8nS5R7XfCqwWAH8sTPfylhRdD5cnOUZ5xKdqouFf0gNv4lOC2WhhNrg240= X-Received: by 2002:a05:6602:150e:b0:835:4278:f130 with SMTP id ca18e2360f4ac-85555e1283dmr467896239f.13.1739397908131; Wed, 12 Feb 2025 14:05:08 -0800 (PST) MIME-Version: 1.0 References: <8ac6a1dd-db82-4ea7-8186-0c354d79049f@aklaver.com> <9fa75099-1ee9-43de-ac6e-945841b184eb@aklaver.com> In-Reply-To: <9fa75099-1ee9-43de-ac6e-945841b184eb@aklaver.com> From: Marcelo Fernandes Date: Thu, 13 Feb 2025 11:04:57 +1300 X-Gm-Features: AWEUYZkJRCDnZp-mfbmRGtlIhQwAacS2-cKmeq1da7AodhHPZ_-QfpcLOj4I8qs Message-ID: Subject: Re: Best Approach for Swapping a Table with its Copy To: Adrian Klaver Cc: pgsql-general@lists.postgresql.org 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 Thu, Feb 13, 2025 at 10:40=E2=80=AFAM Adrian Klaver wrote: > Do you know this will not fail on the existing data? Yes, all the current data in the original table respects the constraint. > Do you have room for a complete copy of the table? Yes, in this scenario the copy is already created, and triggers keep the co= py in sync with the original table. > I am not seeing how this can be done without some outage for that table. Swapping tables without an outage is possible. I believe that this somethin= g involved in the process repacking a table when using pg_repack as it relies= on copying the whole table and then swapping it for the original. My main question is "How?". I know that the pg_repack involves swapping the relfilenode values and something about TOAST tables, but I am not super acquainted with pg_repack code or debugging tools to verify precisely what = it does. > What sort of time frame is acceptable? The scan phase in this table is very slow, on top of it the exclusion constraint needs to create the underlying index to service the constraint. Anything that takes more than 10s in this system is prohibitive, in this se= nse creating the constraint without having a table copy is not viable for the s= ize of this table. Regards,