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 1qQMQZ-00DeTC-Rz for pgsql-performance@arkaria.postgresql.org; Mon, 31 Jul 2023 06:30:47 +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 1qQMQX-00CIpl-PM for pgsql-performance@arkaria.postgresql.org; Mon, 31 Jul 2023 06:30:45 +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 1qQMQX-00CIpc-9U for pgsql-performance@lists.postgresql.org; Mon, 31 Jul 2023 06:30:45 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qQMQU-001PLF-Sy for pgsql-performance@postgresql.org; Mon, 31 Jul 2023 06:30:44 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3fe12820bffso18060185e9.3 for ; Sun, 30 Jul 2023 23:30:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20221208.gappssmtp.com; s=20221208; t=1690785041; x=1691389841; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=JUWuYX5+sULHTpZwntrnn9VOTJPKSlfsATIA+SPwmxw=; b=ZPGd9lGbHoQdnJUZTYDAUkwm94zIr0AMm4Il0lNtCC5JcxGbXbGbSQrBopt7Cy2nB8 +AH8DrT2S85ppz9kHvDZwtODFxUIjmXrsdb6eNwaNYLgsxzNcI6z1u6ntjlKqIDzDRZR GZlhbBhiDUdoT4eVkPM8ipFdVp1V2Q4L6oJ3Yy3/5k4tKcgv1vQlBAvzCqdchGjEHJKR PcXluqny3ldlomo4UZ5JKiT7jndNOOqQw7mQKdtYR9czIlNK0Vp9jQF+yROiMa3ctusL etnVqp2UApWjzr+GCZ2jNIm4Qnp7PV04jNrTvMmXt1ydru44OUhYvhwAwC0khuPg28xf lefQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690785041; x=1691389841; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=JUWuYX5+sULHTpZwntrnn9VOTJPKSlfsATIA+SPwmxw=; b=Rptzn7w4AnpxH4F0AmVp2i0kXkAtkbokrtt44kxo8Y2PCf7EOkzCZGtvgxc6en1VKF YrBCzQ4CzFf/v8283fzQItXDwD5TXGzyRm9AJ9tLrWiaDaK27YRzVPpt18VtY9zAQTbt o4VmIWHlsoZZML/4QNh1bpQv5nuJ3p5ZtP4Gy6IOeI0+Zy08vWjqcyePiBAwy0eoNLYW TJch7pt0dVW+aCFYe2AhQsSWrfq4vtAx/qXwMWCt2v2nlvS27DQUBkWgp9UsrTOLy7zq 3B+xspvXixxtLXR/cTBGQqwCmkgcDhEwhdNBb6BeFELwTuOvNN/hZTDRjW51Ug4LHZzJ hpmw== X-Gm-Message-State: ABy/qLYuuooiVrGKbtBJbzYOy6e0yioyinBYOoM43OwMSnimzajApdAW HguADV3QS22jzN+EsUplYjeqjfjphK1EIPUJ8As= X-Google-Smtp-Source: APBJJlERJk9h529XEufNfy7MIogOnM2eLiJOMcCorSVDZ9C6Nye5ZgHmB95yNkx545sflcHrXtCBqQ== X-Received: by 2002:a7b:c385:0:b0:3fe:111b:7fc4 with SMTP id s5-20020a7bc385000000b003fe111b7fc4mr4803721wmj.21.1690785040446; Sun, 30 Jul 2023 23:30:40 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:560:1a5f:5717:db:6b3a]) by smtp.gmail.com with ESMTPSA id m9-20020a7bce09000000b003fe1ddd6ac0sm3119267wmc.35.2023.07.30.23.30.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 23:30:40 -0700 (PDT) Message-ID: Subject: Re: Table copy with SERIALIZABLE is incredibly slow From: Laurenz Albe To: peter plachta , "pgsql-performa." Date: Mon, 31 Jul 2023 08:30:39 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, 2023-07-30 at 23:00 -0600, peter plachta wrote: > Background is we're trying a pg_repack-like functionality to compact a 50= 0Gb/145Gb > index (x2) table from which we deleted 80% rows. Offline is not an option= . The table > has a moderate (let's say 100QPS) I/D workload running. >=20 > The typical procedure for this type of thing is basically CDC: >=20 > 1. create 'log' table/create trigger > 2. under SERIALIZABLE: select=C2=A0* from current_table insert into new_t= able >=20 > What we're finding is that for the 1st 30 mins the rate is 10Gb/s, then i= t drops to > 1Mb/s and stays there.... and 22 hours later the copy is still going and = now the log > table is huge so we know the replay will also take a very long time. >=20 > =3D=3D=3D >=20 > Q: what are some ways in which we could optimize the copy? >=20 > Btw this is Postgres 9.6 >=20 > (we tried unlogged table (that did nothing), we tried creating indexes af= ter > (that helped), we're experimenting with RRI) Why are you doing this the hard way, when pg_squeeze or pg_repack could do = it? You definitely should not be using PostgreSQL 9.6 at this time. Yours, Laurenz Albe