Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDjDn-00035q-Ol for pgsql-performance@arkaria.postgresql.org; Fri, 27 Sep 2019 05:55:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iDjDl-0000Bq-0x for pgsql-performance@arkaria.postgresql.org; Fri, 27 Sep 2019 05:55:13 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDjDk-0000Bj-J6 for pgsql-performance@lists.postgresql.org; Fri, 27 Sep 2019 05:55:12 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDjDh-0007ae-8a for pgsql-performance@lists.postgresql.org; Fri, 27 Sep 2019 05:55:11 +0000 Received: by mail-wm1-x343.google.com with SMTP id m18so4802052wmc.1 for ; Thu, 26 Sep 2019 22:55:08 -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:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=rFWPgSEE4xQUaIpjr7EBCIvfPf3oZiACQ8neZG6rtws=; b=f7ak8rRE82TDGbdgtgL+Yifdw3g7clVeYLALtEn26A9PfCuQ0WYVZJYEXwfLk9LruA iPrBfKIoLpTL3ih3RkzgtoH5i3qROnUVvDtJAgCcOY+Q8tiVW9ubXt+ShvXMiyCl64/X V700z1EtrAALfmTh6M5tpVsKCHtx2ZllQQVUUju9ax6rfeUmcheBe88AfWGDR5h6bfFJ J5HQGhJchHU073JNFyzg++0C3GsKQL6Uniw+eQeMd/N0S9U6iiBjGYtt4sVqtQefB7Dr NX7+jnxNKTy9lEoIN+gvusfDdBJrzZymnhHBUbFIIHLt45O8+pGsINt3o/DxanAxqrGl nuow== 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:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=rFWPgSEE4xQUaIpjr7EBCIvfPf3oZiACQ8neZG6rtws=; b=WDB5cnVIk1YNtoPflU4/O4SvhJQoDserrRFOWO0xnn0w8AyvFB58yr2shqnSiVa3FN jhLUeWvMV6jhto1+dBiOXHz9vzCIXftqovXntVan1lJilM793cgM4Pki5jqT+VHx4Gtu NOuZHw3vug6zJMniqBrqsGKKLV2KGlpAvpTNrU0YOPBNLZceZEItsnIJpdSmXE3ZsWNR OgaNLn27oWsiTGUMvMUh1Nb8TPgjVuuocT0Rma8/uIooX7SlxuMdtAA5IV9PFqBoNsfF 8tSrqs+4nmJsqSHrWkUao7UxVb39aiZ26riiXb1qxynqKh/JPTmCbw2AbRcCdD6dUgGX un+Q== X-Gm-Message-State: APjAAAUUMZrQBri4jrSetzWgvEToi/scfhWbPEBHBUXFkkmWUluUCxSA eANSyCx/n8tQCQBWIxfEm959Pw== X-Google-Smtp-Source: APXvYqz/W5OKQMfiWC4yjtCZG/ZAtK5LGNQV8pbtsOwSL3tCEZP9g70YU5K6tvmec1xxatKbUxQN7w== X-Received: by 2002:a1c:2089:: with SMTP id g131mr5467973wmg.33.1569563708269; Thu, 26 Sep 2019 22:55:08 -0700 (PDT) Received: from localhost.localdomain (mobiledyn-185-69-244-105.mrsn.at. [185.69.244.105]) by smtp.gmail.com with ESMTPSA id x5sm3330706wrg.69.2019.09.26.22.55.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2019 22:55:07 -0700 (PDT) Message-ID: Subject: Re: Autovacuum is cleaning very less dead tuples From: Laurenz Albe To: Amarendra Konda , pgsql-performance@lists.postgresql.org Date: Fri, 27 Sep 2019 07:55:06 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.4 (3.32.4-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, 2019-09-27 at 11:10 +0530, Amarendra Konda wrote: > As part of vacuum tuning, We have set the below set of parameters. > > > select relname,reloptions, pg_namespace.nspname from pg_class join > pg_namespace on pg_namespace.oid=pg_class.relnamespace where relname > IN('process_instance') and pg_namespace.nspname='public'; > relname | > reloptions > | nspname > --------------+---------------------------------------------------- > ------------------------------------------------------------------- > -------------------------------+--------- > process_instance | > {autovacuum_vacuum_scale_factor=0,autovacuum_vacuum_threshold=20000,a > utovacuum_vacuum_cost_limit=1000,autovacuum_vacuum_cost_delay=10} > | public That's not so much tuning as breaking. You have set autovacuum to run all the time at a snail's pace. That way, it will have trouble getting any work done. Don't touch autovacuum_vacuum_scale_factor and autovacuum_vacuum_threshold. Don't raise autovacuum_vacuum_cost_limit. If anything, lower autovacuum_vacuum_cost_delay. > However n_dead_tup value from pg_stat_user_tables was always showing > very high value. Most of the time, it is greater than 100K dead > tuples. That is only a problem if the number of live tuples is less than 500000. > Overall, we couldn't able to correlate on why autovacuum was able to > cleanup only < 2K tuples, even though there are mode dead tuples > based on the statistics ? Can you please explain on why we are > notcing huge difference and what steps needs to taken to minimize the > gap ? It is questionable if there is a problem at all. > Log message > > 2019-09-25 00:06:31 UTC::@:[80487]:LOG: automatic vacuum of table > "fc_db_web_2.public.process_instance": index scans: 1 > pages: 0 removed, 854445 remain, 0 skipped due to pins, 774350 > skipped frozen > tuples: 1376 removed, 16819201 remain, 21 are dead but not yet > removable > system usage: CPU 44.57s/33.04u sec elapsed 5088.65 sec This shows that at least this table has no problem. Even with your settings, autovacuum finished in 5 seconds and could clean up almost everything. > Live and Dead tuples > > select relname, n_live_tup, n_dead_tup FROM pg_stat_user_tables WHERE > relname='process_instance'; > relname | n_live_tup | n_dead_tup > --------------+------------+------------ > conversation | 16841596 | 144202 Perfect. There is no problem at all. The table has less than 20% dead tuples, so everything is in perfect order. Just stop fighting windmills. Give up your tuning attempts and reset all parameters back to the default. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com