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 1o91kf-0000Rg-UD for pgsql-general@arkaria.postgresql.org; Wed, 06 Jul 2022 09:55:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o91ke-0001g7-Qo for pgsql-general@arkaria.postgresql.org; Wed, 06 Jul 2022 09:55:20 +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 1o91ke-0001fw-FD for pgsql-general@lists.postgresql.org; Wed, 06 Jul 2022 09:55:20 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o91kd-0005Xg-0g for pgsql-general@lists.postgresql.org; Wed, 06 Jul 2022 09:55:20 +0000 Received: by mail-ed1-x533.google.com with SMTP id z41so18604652ede.1 for ; Wed, 06 Jul 2022 02:55:18 -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=8nANePwUXYMlR6HOZ90aOPejgPXBm4UEM9pHoagtpOQ=; b=WgznNGBCl3zeYBzVK0KQC5AorlECmOgLyj2aLui4rR9V+Sc9YbffRdgVKj9XpUUA/q ZQMNPb3AnFSdrKypLTNEpZHifIhMncnKTSLNggB6b1OdqyVWjgnewS6v1O0m1RVHLPde 8qwV9SxpFRCYeT/YXnNz9Mf0rCl4eg1Bw6vS1+K0wws2Pzp2fqTR8xlVhaAAfZFh+RuZ EIzcI3r+G8c9pMtn3G5TGs93U8hqWkUDvafm62l0yUqvP3IVlyZki2qAhEa8ZqssBRvE SVonS3k+z2EZDhptpy9lktRZyGlYnl3SnWw1SuPNEPeXqephKrGJ6tud9CSPxf/cl4fr skWw== 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=8nANePwUXYMlR6HOZ90aOPejgPXBm4UEM9pHoagtpOQ=; b=5RzrUFv4IhJX6v8AgxfTuj1r6FqQEdAg/lC6PDk5CoqYy3/CrlUX2NW+T1bThAYSdN N/6ufH1DvYgRU7sDwhky4hjishQfRdoEj2KvUwR6UnVL27O3gIPPcOK68Cn/mG9exOuG SmK/wPf+NHYITH7gniA4PZtzBoJUUEMIVATp52+le3H6QLBx7WyALATaKN2OGc4FFQSM z6021UBm3EJZsJwDZKKysn7Jxx7B865R3LmUwjqwlbwO1b87tVlWxPNwDMCGE2DlOa6k KT78IxJ1hT5OuVmNNFAwQ4RTqFeBeCRNvCIpWg2xusAU2crFZHTSs4DTkobEDFTogfn+ HkTg== X-Gm-Message-State: AJIora9WAJH+VFxqtyBP5EoMLGX236BoRQp/VHWXhb9TB7M3TAbzd6re 2AfZOoE83RPBTOTrj8vdcGw= X-Google-Smtp-Source: AGRyM1tWXH5cViwHpECGqFROvI+qbMvR4+Fzy3eocmr5TXtHfUNljg1cMB0fCHqVNv8PKdPccrJFvA== X-Received: by 2002:a05:6402:2804:b0:439:83c2:8be2 with SMTP id h4-20020a056402280400b0043983c28be2mr37617429ede.292.1657101317657; Wed, 06 Jul 2022 02:55:17 -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 q16-20020a056402249000b00438a13508c4sm13929553eda.51.2022.07.06.02.55.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jul 2022 02:55:16 -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: <4ABCA676-9635-421E-83DC-609E87E967AC@gmail.com> Date: Wed, 6 Jul 2022 12:55:15 +0300 Cc: Peter Eisentraut , pgsql-general Content-Transfer-Encoding: quoted-printable Message-Id: <9E6090C6-74EC-413F-9E3B-E6F2D59E772B@gmail.com> References: <03C74523-7947-42CA-8392-B7CB8EFC16D2@gmail.com> <155880bb-f9d7-a34b-664b-61763b6e8719@enterprisedb.com> <4ABCA676-9635-421E-83DC-609E87E967AC@gmail.com> To: Florents Tselai X-Mailer: Apple Mail (2.3696.100.31) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Also, fwiw looking at top the CPU% and MEM% activity, looks like it does = data crunching work. > On 6 Jul 2022, at 12:48 PM, Florents Tselai = wrote: >=20 >=20 >=20 >> 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. >=20 > 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. >=20 >=20 >=20