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 1o92NY-0002T4-4D for pgsql-general@arkaria.postgresql.org; Wed, 06 Jul 2022 10:35:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o92NX-00017q-0f for pgsql-general@arkaria.postgresql.org; Wed, 06 Jul 2022 10:35:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o92NW-00016y-Kc for pgsql-general@lists.postgresql.org; Wed, 06 Jul 2022 10:35:30 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o92NU-0000FN-75 for pgsql-general@lists.postgresql.org; Wed, 06 Jul 2022 10:35:29 +0000 Received: by mail-ed1-x52e.google.com with SMTP id e40so18717849eda.2 for ; Wed, 06 Jul 2022 03:35:28 -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=HD9oBWYJfi6fPp65iIY6HfRlBY0D5fo0iwrGmGWxATY=; b=Rm/RHvnlf4ytlAZQMJquY92wxuDRQnvSICx7upj/bjBusJK/LFG0D0REK3JiSLfK5n uFjpjCpIbsBlh/2uqyimKkAz7fBF9Bi9/8GTeE841ICNk5LHCgA3OHih+bhY2t/TR/B+ inQGrrMw/ZFbmv1DBadhkztUwBwinhxP43vO+9Z3O+AXHPxCYLGUG11jn5qp2bfkV87P MAGqfi/aW9TD0dywNlSW1MFsSXP5KucjQUeyitQ53Ab0RqpD7SQ7o3ynKcbs1JAgJRVU sS1vYcyeSPy+KMhvipIww6LYrHSdwgii/QjvE50qqF8Hm0nd5snaItSeVKBuinRDSeEn gBSg== 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=HD9oBWYJfi6fPp65iIY6HfRlBY0D5fo0iwrGmGWxATY=; b=xQkuA2ETAKhzEgd1zYViru9tyziAiOYlFXxUjzjK68jW53JHiJmwsY5JJsQATCup8V 7+oxFbzSwiaRwKpudFGu59siUo25brSc9DIx0RZNW73posfLzNYrCYGcKlE1uV32NdPu wVKtBaMGUH6bZy0sTEA8UxzBZmonzG+MdKMEWoT+xhNFXfWZjxP+/8V2FjVyt6/6Rb2D Bd0v6LIzvKhnOFH1if6K0BUrdFPsW+og5pLo60MfsQTG8kFXoK5OAJUyHIky81Deri/b uh04cwBgsZgk/3tiDdnVvyjBcE2xbVDPErqv19zBO335cV3ZI4x5ifi5uufvwhG+3k5f +dww== X-Gm-Message-State: AJIora8fA7FNm5L9cmqgXtKFpbusPMlpArS7N5blm0SEAI5/WjW12fAK dz4kbk+g5qNzEnXOzcQ4/4c= X-Google-Smtp-Source: AGRyM1vM0w4PKjiPmNOm8T/hPwNP+MQ07AiJ8CiJskUbLXOIOwppAfOBsS4oQUl2WMPA0HpDr4G1xw== X-Received: by 2002:a05:6402:540c:b0:434:d965:f8a with SMTP id ev12-20020a056402540c00b00434d9650f8amr53328734edb.30.1657103726827; Wed, 06 Jul 2022 03:35:26 -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 b18-20020a1709063cb200b0072afb23fb9esm622067ejh.16.2022.07.06.03.35.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jul 2022 03:35:26 -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: Date: Wed, 6 Jul 2022 13:35:24 +0300 Cc: Peter Eisentraut , pgsql-general Content-Transfer-Encoding: quoted-printable Message-Id: References: <03C74523-7947-42CA-8392-B7CB8EFC16D2@gmail.com> <155880bb-f9d7-a34b-664b-61763b6e8719@enterprisedb.com> <4ABCA676-9635-421E-83DC-609E87E967AC@gmail.com> <9E6090C6-74EC-413F-9E3B-E6F2D59E772B@gmail.com> To: Francisco Olarte 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 1:11 PM, Francisco Olarte = wrote: >=20 > On Wed, 6 Jul 2022 at 11:55, Florents Tselai = wrote: >> Also, fwiw looking at top the CPU% and MEM% activity, looks like it = does data crunching work. > ... >>>> 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. >=20 > How big is yout table? from your query it seems you expect more than > 1M-1 ( left... ), but if you have very big text columns it may be > spending a lot of time fully decompressing / reading them ( I'm not > sure if it left(..) on toasted values is optimized to stop after > reading enough ). Also, it has to rewrite a lot of data to insert the > columns, it it takes some ms per row which I would not discard 50M > rows * 1 ms / row =3D 50ksecs =3D 500k secs ~=3D13.9 hours per ms-row, = so at > 2 ms ( which may be right for reading a big row, calculating the > vector and writing an even bigger row ) it would take more than a day > to finish, which I would not discard given you are asking for a heavy > thing. 50M+ rows and iirc pg_relation_size was north of 80GB or so. >=20 > If you have stopped it I would try doing a 1000 row sample in a copied Haven=E2=80=99t stopped it as I=E2=80=99m not convinced there=E2=80=99s = an alternative to just waiting For it to complete :/=20 > table to get an speed idea. Otherwise, with this query, I would > normally monitor disk usage of disk files as an indication of > progress, I'm not sure there is another thing you could look at > without disturbing it. >=20 > FWIW, I would consider high mem usage normal in these kind of query, > hi cpu would depend on what you call it, but it wouldn't surprise me > if it has at least one cpu running at full detoasting and doing > vectors, I do not know if alter table can go paralell.. >=20 You=E2=80=99re probably right, a lot of the CPU usage could be = detoasting. > Francisco Olarte. >=20 >=20