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 1jkpJ5-0004dU-3K for pgsql-general@arkaria.postgresql.org; Mon, 15 Jun 2020 13:37:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jkpJ4-000175-05 for pgsql-general@arkaria.postgresql.org; Mon, 15 Jun 2020 13:37:46 +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 1jkpJ3-00014H-OI for pgsql-general@lists.postgresql.org; Mon, 15 Jun 2020 13:37:45 +0000 Received: from mail-ej1-x641.google.com ([2a00:1450:4864:20::641]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jkpJ1-0002cQ-Pd for pgsql-general@postgresql.org; Mon, 15 Jun 2020 13:37:44 +0000 Received: by mail-ej1-x641.google.com with SMTP id q19so17468776eja.7 for ; Mon, 15 Jun 2020 06:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=thP38GAkutN5AzFjfa0clgcpM95HTSWN4CUQwmYyFvw=; b=OOzgBeY9o5FgTca9Vd9fiS0YOVOOKk/pe2k5Um8JMccksKX5eLx1G01+H4LfQoMP0g O2EAyEcxzn922aB6St647bPE25WJuAiVdYG76RTXyUg8hLt8L10N+d9TGDdhShN4KjEy 0Wvw4wiXAWTH1vs/c/iu4WJ4qI0DQBWd3cqQPRiNzubNDuSj/4wDn0LouNueZr5QvGh8 260qBkSu3GdRfhbjQ+nYLfB2szNUiB1xsL/j5PwJG6a27OIoaZvbGYHXqjjc7f+xVVbY HZrpf9UZAX3qcwISivBx1+BoXyBOt8Zd1awiVNNPNv5Y3wR/pDZmUv9FgHOYdpyS9A/o vr3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=thP38GAkutN5AzFjfa0clgcpM95HTSWN4CUQwmYyFvw=; b=hVck+r533UgzwkHLdUIjSUKHwIvDm0YPVzbFLBX+Vm0L9R/aLWHkuUAHgaVXjKtj/V dMPjBYymusjzBkYnPyKaGNV3j7yZz32MofjW3ilxApoAGDqG5iwurA04thkAh5sw1MW4 5dAqt2DBhRDgT8TVCMfPduTpgg8D1p8LgqvN6gPh2U1xQd2ZYm6tGJXf4qBUcwmJKNu2 rWA0FPU+U+KAbMJ6TdNRvyGDFUNQz6RuqzUM5Pmn/psHl3NsBBSlGp5EPjIPapAXlcu2 4Uumf2W97CRP5ppt9UlUY0oE7wqliDHRFRHYxJquwoeeXtv0YgA6uYj74mXEpsvt8N3f DvZA== X-Gm-Message-State: AOAM532GvCM905+UPnGGFA4cGzvBzfVal2IvnCJ/ZQZBjCOWu/ePu+W0 NwHb0eYvTVrdZHFCNRsiSq1aB9wlCCU= X-Google-Smtp-Source: ABdhPJx4Ho5L/h/b69+kcEBXqydf9XqOma82ba0Bv3pM0BfV5ldPODLnPqP9bn2/mYdiZD0lF9uHYg== X-Received: by 2002:a17:906:14db:: with SMTP id y27mr26375296ejc.225.1592228262368; Mon, 15 Jun 2020 06:37:42 -0700 (PDT) Received: from localhost.localdomain (217-149-168-120.nat.highway.telekom.at. [217.149.168.120]) by smtp.gmail.com with ESMTPSA id o16sm9109506ejg.106.2020.06.15.06.37.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 06:37:41 -0700 (PDT) Message-ID: <78fa342abe358a96601c675729dd1eff0fe5481d.camel@cybertec.at> Subject: Re: TOAST table size in bytes growing despite working autovacuum From: Laurenz Albe To: Kristjan Mustkivi Cc: pgsql-general@postgresql.org Date: Mon, 15 Jun 2020 15:37:41 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, 2020-06-15 at 13:47 +0300, Kristjan Mustkivi wrote: > Still, pgstattuple reveals that the table size is 715MB while live > tuple len is just 39MB and 94% of the table is vacant. I do not have > much experience in interpreting this but it would seem that it is > still getting bloated. Should the autovacuum be made even more > aggressive? E.g toast.autovacuum_vacuum_scale_factor=0.01 instead of > 0.05 and tweaked further when necessary until the size stabilizes > (more precisely pgstattuple will reflect the bloat to be under > control): > > SELECT * FROM pgstattuple('pg_toast.pg_toast_293406'); > ─[ RECORD 1 ]──────┬────────── > table_len │ 715776000 > tuple_count │ 25545 > tuple_len │ 39241366 > tuple_percent │ 5.48 > dead_tuple_count │ 1116 > dead_tuple_len │ 1930508 > dead_tuple_percent │ 0.27 > free_space │ 669701052 > free_percent │ 93.56 Indeed, the table is almost entirely air. You should schedule down time and run a VACUUM (FULL) on that table. That will rewrite the table and get rid of the bloat. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com