Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fpDNu-00019U-Po for pgsql-general@arkaria.postgresql.org; Mon, 13 Aug 2018 13:59:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fpDNs-0007dy-Gy for pgsql-general@arkaria.postgresql.org; Mon, 13 Aug 2018 13:59:48 +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 1fpDNR-0005S1-IO for pgsql-general@lists.postgresql.org; Mon, 13 Aug 2018 13:59:21 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fpDNM-0006uS-8V for pgsql-general@lists.postgresql.org; Mon, 13 Aug 2018 13:59:19 +0000 Received: by mail-wr1-x442.google.com with SMTP id h15-v6so14363875wrs.7 for ; Mon, 13 Aug 2018 06:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=2yHK1E4RYhi4HCwpzJFYAcmBQU23et9I9ECZztXGgkc=; b=h5gDj+s8quQDhRZ8nGItfHetd/61zX2gvQhZgOMXtDcqS7jrUUCojCpR2gGJaamvFS QlTEHG7KzFmchuZEBfiCb3ZvxKe5fEB7G81QitaCDi/0guXgQO7LexD00vcb3GVHzoyH 7QFkGvRfpNptzzpzulzrayseEDgOdcuOQPL7mXDSk2+AcgCBXTw9RUfI80e/y6AMwMbx GcRKvwXQHieXqLMK+XdwUFns+9OvJWnmwFG7Vq0X23O/mWxCu+2UqmXf8H08UTLZTwyh Sj7AZrnW8VS/wAY8ibkFzsupQpFiNpWhS35kL5oisyGS1ab3KLK2v3ZduAfKNnajJ/wQ 3pDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=2yHK1E4RYhi4HCwpzJFYAcmBQU23et9I9ECZztXGgkc=; b=LCBEOmDf5Gqxb35GSLTnAaWhOI/E1wq9pzV6W7AoDiEiEhtw0WgwwK3EZn+uROIN3p dZbFy4/CE6Y6ALCcpPm4857r4MLzoKmzGUnL80nrfNndh5dfQ20QZXdqctJuayS0lbgY Vpmo4cUG+Dz6y0z8+samSua4g6ZopM0XkGsuNpLHKinkKnkdFVMpkmMk99ktrlvoXKsk gEl2vVj4EOpANm1Qz/k75OpEb8N0ppbqHDnG+ASXW0h4JM0B2N1AQwes+XFe+LAgy5Uo mq71nQ+w+DGeQ8ySH25+sKPfbiBWo8wZoTCgUv7MucA4xoIlYPMcT4FLEphb4QDy3bRj oNJw== X-Gm-Message-State: AOUpUlGCmFmh8XL1EG3n3q2r9zFYQySOdDaNDc9VtPeGismr3xXqXU7M GNrR2IG6rF7j/2k6dTncD01JoFVFyEImIdzvbJnaLWuL2glcAE9k08dN3ROe+Qwi2ebk2FaPQaA 7HUeFu9c/soDqKVA4QBuFuAlTEqaYgm6FuLgdWkx81GqDgjrECLh5+yoYCKjm7FbI22dLn0pz0s 7NJ0f3PtdRu1sDeJAjtzE= X-Google-Smtp-Source: AA+uWPzkdtwGzeF/EAXBReJ5F4uDUS0Me4ebS4sbYOUkDVCWb4SrvB5HHQSwuiefxoJRLlgrMXVlXw== X-Received: by 2002:adf:ad38:: with SMTP id p53-v6mr11269729wrc.10.1534168753836; Mon, 13 Aug 2018 06:59:13 -0700 (PDT) Received: from [10.137.2.21] (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id b124-v6sm5115743wmg.47.2018.08.13.06.59.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Aug 2018 06:59:13 -0700 (PDT) Subject: Re: is there any adverse effect on DB if I set autovacuum scale factor to zero? To: Raghavendra Rao J S V Cc: pgsql-general@lists.postgresql.org References: <64b01682-49bd-8577-45de-0114fd6af372@2ndquadrant.com> From: Tomas Vondra Message-ID: <5e337338-eadc-1bac-3775-ba7489963415@2ndquadrant.com> Date: Mon, 13 Aug 2018 15:59:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 08/13/2018 03:41 PM, Raghavendra Rao J S V wrote: > > Hi Tomas, > > Thank you very much for your response. > > As we  know table becomes a candidate for autovacuum  process based on > below formula. > > > *Autovacuum VACUUM thresold for a table = autovacuum_vacuum_scale_factor > * number of tuples + autovacuum_vacuum_threshold* > > > > *Current settings in my database are as follows.* > > > /autovacuum_vacuum_scale_factor = 0.1/ > > /autovacuum_vacuum_threshold = 40/ > > > > Due to above formula the dead tuples are accumulating based on the > number of live tuples as show below picture. > > > > select relname,n_live_tup,n_dead_tup,(n_live_tup*.1+40) > expected_to_autovacuum,* from pg_stat_user_tables > where  n_dead_tup>800 > order by n_live_tup desc > limit 100; > > > > > In order to avoid the dead tuples accumulation I wold like to change the > auto vacuum  settings in *"postgresql.conf"* as below. > > /autovacuum_vacuum_scale_factor = 0.01/ > //autovacuum_vacuum_threshold = 100/ > / OK, so the tables apparently have enough dead tuples to trigger vacuum. That mean the autovacuum throughput is insufficient to do all the cleanup. If you lower the scale factor, the amount of cleanup will *increase* (more tables being eligible for cleanup) making it less likely autovacuum can keep up. You need to increase the throughtput, by increasing vacuum_cost_limit or something like that. > *Kindly guide me your views. Does it cause any adverse effect on DB.* > * Well, it forces the database to do more stuff / more often, so it may have adverse impact, of course. It's hard to say if it's going to be a win overall, because we don't know how serious is the bloat. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services