Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3JHV-0006RS-T0 for pgsql-general@arkaria.postgresql.org; Tue, 03 Apr 2018 10:35:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f3JHU-0004fP-Jq for pgsql-general@arkaria.postgresql.org; Tue, 03 Apr 2018 10:35:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3JHU-0004ek-9Y for pgsql-general@lists.postgresql.org; Tue, 03 Apr 2018 10:35:12 +0000 Received: from mail-yb0-x243.google.com ([2607:f8b0:4002:c09::243]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f3JHQ-0003JY-O1 for pgsql-general@lists.postgresql.org; Tue, 03 Apr 2018 10:35:11 +0000 Received: by mail-yb0-x243.google.com with SMTP id e3-v6so6009540ybk.1 for ; Tue, 03 Apr 2018 03:35:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=EUVBcW7bs+qkm1upp/bnrzTPaWsMLNBh+CWe3xrOWMg=; b=roQXICoNuEf5OFwJIriox1d3igr77kCftKJ4u2KV5UsBgSbfcO5sJ/3fGjKn7kyPSp STr/Q+hzw/9UJ6jLzE4+i5C0XyMFzFJUmj0YY2jZ4Fws6/I6Y3gcODT0U8FNQAzJF9AT pOEjHjZtKqWRzcFWiGbwFGcPtlKBYeh9Ek25FJ1WN2yuuXgWn+Tls2SDloYv4l6dQNWP +axD6bCrnWavf/jYs1CzUNBDbueePFYHoUKXSoYMsbOCt88RFqKYitptOqTiEryWu17b ZhlCtM/r+adtK0iisB/1ZVCTpeqshyGjAMrXtzAfczMx7PA6moO/ez8uoXbdZLJN5xlH ugUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=EUVBcW7bs+qkm1upp/bnrzTPaWsMLNBh+CWe3xrOWMg=; b=Xo+TyKIOm3eEgGNNWRdT7hJNesCfXEOLhe1NjvoeHfLph1T6GU3SMXNYkd2KVPMuYw ECXOa30SxlBpF+gBJ43QauiC8i1hUOM/S5G8P36h9Xfcem2/mJVAQLJi2nAxV9XkepZs K103F5ghhqUxtRc+310pqIGnWqn7b1k/pjBvEM7VtyA0QmBLtUTptb0S6NvgS6OGWz5c odwlfBXFTOcnkLoXD7ejkZnGQyrYywx7h5+Itgq+Y6Np+T2XodVxkSCd0OvuvsYNyuqg DClOndI7vppeSBfoaC44PVzpVlmbbnrM6dedZ+CxOOVyIvMRH69667nIl8nCytqjvnSG dGcA== X-Gm-Message-State: ALQs6tCB+T9NrUNGWU+sCzAnN6U9lIehAx9TCz7cxaXJAqKeqxBTBfuT jNh9tvWdX2BiocVp1f7NHSTFEi/o X-Google-Smtp-Source: AIpwx4+k9L7ZBJwDjQoUUkT8vhC5VLIZOg4zTvbETPOzDXgrTG3TnOxRatL/d3XtBZw0fk4jYvBilw== X-Received: by 2002:a25:2e04:: with SMTP id u4-v6mr538183ybu.318.1522751706320; Tue, 03 Apr 2018 03:35:06 -0700 (PDT) Received: from [192.168.1.194] ([193.93.78.27]) by smtp.gmail.com with ESMTPSA id i63sm1009092ywf.90.2018.04.03.03.35.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Apr 2018 03:35:05 -0700 (PDT) Subject: Re: Autovacuum Problem To: pgsql-general@lists.postgresql.org References: From: Vitaliy Garnashevich Message-ID: <3386d532-f1bf-1851-74ab-82318cec2e9d@gmail.com> Date: Tue, 3 Apr 2018 13:35:45 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > > However no space seems to be freed to the system. > > Is there any way a bloody newbie can debug this behaviour? In our experience, autovacuum is able to contain bloating of table data, but not bloating of indexes. You could see where the bloating is by running the following queries: CREATE EXTENSION IF NOT EXISTS pgstattuple; select c.relname, (pgstattuple(c.relname)).* from pg_class c join pg_namespace n on (n.oid = c.relnamespace and n.nspname = 'public') where c.relkind = 'r' order by c.reltuples desc; select c.relname, (pgstatindex(c.relname)).* from pg_class c inner join pg_namespace n on (n.oid = c.relnamespace and n.nspname = 'public') where c.relkind = 'i' order by c.reltuples desc; The first SELECT query gives some information about table data, the second SELECT query is about indexes. The queries will take quite some time to run, because they will have to scan through every data page on disk. Look at the following columns: pgstattuple.free_percent - percent of table data which is allocated on disk, but does not currently contain any actual data (describes table data bloat). pgstatindex.avg_leaf_density - percent of stored leaf index data within the totally allocated on disk (describes index bloat). It's 90% by default. It's not good when it drops too much (e.g. to 50% or 10%). Look at the biggest tables/indexes first. In our case, from 1000+ tables there are only few which contribute most to DB size bloating. But in general that would depend on your specific case, and the write patterns which you application does. You can then do VACUUM FULL for those specific tables, or REINDEX TABLE/INDEX for specific tables/indexes. VACUUM FULL or REINDEX TABLE may work faster than doing REINDEX INDEX for several indexes of the same table. I do not know any efficient way to prevent bloating of indexes. Regards, Vitaliy