Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o91eC-0000BV-R7 for pgsql-general@arkaria.postgresql.org; Wed, 06 Jul 2022 09:48:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o91eB-0000tB-M9 for pgsql-general@arkaria.postgresql.org; Wed, 06 Jul 2022 09:48:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o91eB-0000rj-9H for pgsql-general@lists.postgresql.org; Wed, 06 Jul 2022 09:48:39 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o91e9-0005Pv-5T for pgsql-general@lists.postgresql.org; Wed, 06 Jul 2022 09:48:38 +0000 Received: by mail-ej1-x62b.google.com with SMTP id lg18so6325531ejb.0 for ; Wed, 06 Jul 2022 02:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ZQTeUhXpkad9E1DOcvtOr5PTMgfh7H3lO/6pzTAuk8c=; b=ciZxaspSIY++E68/aiVFmzze4q+Kow26kDLwYV0WOj6U0Y6rwnxmcer/3WfCCCEs8Y G+kLbL7m++nsIe9yoe8aTW783jw5gF5swPckACAhbm1dnaqkyLoXe6C5z7a2gklT+g/y zVdepCqnR0/5oTHVAAJnelRrSMvwe4E09OTWDx0McGsoIJkiKxwvuEPL6m5FzH236oHu iMJsuBvl6dgyyjd66ml20DP2//6Y1JiD4ki641LmC0NMwbPOvYiLTLY+GFRoRfMB4OkD 9+CbVGpL4bUMPAp49Txv65ynBBHaZq6ToWr95R0XJCqgKBUDjLZY9/7EqYJ4BviXg0ue jCnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ZQTeUhXpkad9E1DOcvtOr5PTMgfh7H3lO/6pzTAuk8c=; b=EwAogyYjNNUGQQJ3o3Qt87rvrpfBkUjJF/mj2JOp/n5AGspj8O0JN1mIkcHbLDWPli nzixo7oGPjEFMjB876Jpe845ukKPPar72H664XHZm9ND4WlRcxbZBRE8ZMxJiwIL7/Q9 uLcsOhXBWhamGi00VOumxXwJNI2vlGhWAkUJaYOYTejrgrJaFaJpRjDkkuVaLYedEhI7 ygpi7dawj/SUUPVEIHFgVU0lqHJOgp33IscJoskIuxytgzxl/Qd2hIhTvEBIXr5OcLa4 VamfXFsEN9pYn6U+Dees7QYF/2MEbik96uoagEaqnop6/DkHb9bK/hiAKSW6pOCp5QCG N7cQ== X-Gm-Message-State: AJIora8UR/W52suLjs3zoPGHadCsxpSdJFR/PLaTeodF6BOrbKyVOEeo NM9k42aRdENfY5ctQrr7s14= X-Google-Smtp-Source: AGRyM1vXs060uf3cQhFKevZtKU93NhcDP0L5T3F1cYDZt4ZhTFRdoMYVTw1zSc7WAdl7FYICHP9Gfg== X-Received: by 2002:a17:906:9bef:b0:72a:e6c3:e1fc with SMTP id de47-20020a1709069bef00b0072ae6c3e1fcmr7205961ejc.453.1657100915977; Wed, 06 Jul 2022 02:48:35 -0700 (PDT) Received: from smtpclient.apple (ppp-94-66-221-5.home.otenet.gr. [94.66.221.5]) by smtp.gmail.com with ESMTPSA id k27-20020a17090632db00b0072ab06bc3b5sm5550517ejk.34.2022.07.06.02.48.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jul 2022 02:48:35 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) Subject: Re: ADD COLUMN ts tsvector GENERATED too slow From: Florents Tselai In-Reply-To: <155880bb-f9d7-a34b-664b-61763b6e8719@enterprisedb.com> Date: Wed, 6 Jul 2022 12:48:34 +0300 Cc: pgsql-general Content-Transfer-Encoding: quoted-printable Message-Id: <4ABCA676-9635-421E-83DC-609E87E967AC@gmail.com> References: <03C74523-7947-42CA-8392-B7CB8EFC16D2@gmail.com> <155880bb-f9d7-a34b-664b-61763b6e8719@enterprisedb.com> To: Peter Eisentraut X-Mailer: Apple Mail (2.3696.100.31) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 6 Jul 2022, at 12:38 PM, Peter Eisentraut = wrote: >=20 > On 06.07.22 10:42, Florents Tselai wrote: >> I have a beefy server (40+ worker processes , 40GB+ shared buffers) = and a table holding (key text, text text,) of around 50M rows. >> These are text fields extracted from 4-5 page pdfs each. >> I=E2=80=99m adding the following generated col to keep up with = tsvectors >> ALTER TABLE docs_text ADD COLUMN ts tsvector GENERATED ALWAYS AS = (to_tsvector(=E2=80=99simple', left(text, 1048575))) STORED >> I expect this to be slow, but it=E2=80=99s been running for 18hrs = already and I certainly hope I=E2=80=99ve done something wrong and = there=E2=80=99s a smarter way. >=20 > Maybe it's stuck on a lock? ALTER TABLE / ADD COLUMN requires an = exclusive lock on the table. Looking at pg_locks and pg_stat_activity doesn=E2=80=99t seem like = it=E2=80=99s stuck behind something like ACCESS SHARE or similar.