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.92) (envelope-from ) id 1j930y-0003wQ-5a for pgsql-admin@arkaria.postgresql.org; Tue, 03 Mar 2020 08:34:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j930v-0002RI-U6 for pgsql-admin@arkaria.postgresql.org; Tue, 03 Mar 2020 08:34:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j930v-0002RA-E9 for pgsql-admin@lists.postgresql.org; Tue, 03 Mar 2020 08:34:53 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j930o-0006E6-AW for pgsql-admin@lists.postgresql.org; Tue, 03 Mar 2020 08:34:52 +0000 Received: by mail-wr1-x441.google.com with SMTP id r7so3233215wro.2 for ; Tue, 03 Mar 2020 00:34:45 -0800 (PST) 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=BXYuPcdE0oMsBGja0MUZqHANJgJXojTcSObeo4kl+Yg=; b=lrA6MjazvZXDyCVNAt10LdA+OEstOnUJIq4NT2us1vXQE4iPaq+DR6/v5SppHKk8a+ eeMAP5QYRcRwety4c9jEWTkfRrS12ZtRlTHJslgvwWJ2G+imZV3wufxdaYMQ90IIthDH YNeIapKrgCSgqQSXRu9u921OMtvx9oZcSCZWWDjOy/Js0i5L3PUs51c1gYh9plOJUYDd BZRvg6LFJmfwN7mPIHMUZGMT7gZjUJI9/D6sya0APqb5UionMZohuUUncBzegSS2udkA HUb8ZjoJTVu5QwXncYzM+He0XHMBLEcfOEVIynKtFNkba/83a+BKdtAlCPl62xLpC0sM 216A== 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=BXYuPcdE0oMsBGja0MUZqHANJgJXojTcSObeo4kl+Yg=; b=b0MD4e2Ls07L3iYYR3n+hsoOtqzCPlcNQYwpAc3+A+OlWfPZb/0Frp8+h+324xrWjX cHU6tGOOQJPIDdMuWemf1vgByOOs3HkFekXw0yLm+Qo2CqpyfUqirHNCUEUMMJ/EZGbn 2gNbiwI+te5pZMSCmirZlTS+RAGT1bC75CSlCtb/vGHQnNGgFGwMBijhD2UCXj8AGnnd v14hGAUyWzYTcS6g/W3bgGACEt/kDuMbGSTJ4LCcc50h3wDrFjAYA3BzAejNxteISIJ/ Lt5YEXEN6+H1mcSYptHFq2BRpuuoqQW2Mb0/pXOJ4omaFEgODVIURwq7bYWaQ6MiyFSv etyQ== X-Gm-Message-State: ANhLgQ2EgqXFCCLE82jCNJrz4Ae3VlhJzQiWasbl8ycG6MHFg1x2+8D8 l2BiTLp+Ln8MgzFwvKcSXKn/8A== X-Google-Smtp-Source: ADFU+vvo/up8HGV+X8EXFBBPHQ0IkE6f8UL6iFAy11m9HqvM2Bt7+km8vwplQN0J1r5ze8DWNOvj0A== X-Received: by 2002:a5d:4206:: with SMTP id n6mr4148392wrq.119.1583224483605; Tue, 03 Mar 2020 00:34:43 -0800 (PST) Received: from localhost.localdomain (217-149-173-41.nat.highway.telekom.at. [217.149.173.41]) by smtp.gmail.com with ESMTPSA id b10sm32807750wrw.61.2020.03.03.00.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 00:34:43 -0800 (PST) Message-ID: Subject: Re: Autovacuum/Analyze Doesn't seem to be running properly From: Laurenz Albe To: Chris Kim , pgsql-admin@lists.postgresql.org Date: Tue, 03 Mar 2020 09:34:42 +0100 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: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, 2020-03-02 at 19:57 -0700, Chris Kim wrote: > I have a cluster with these parameters (no changed settings for any of the database/tables): > > autovacuum | on > autovacuum_analyze_scale_factor | 0.05 > autovacuum_analyze_threshold | 25 > autovacuum_freeze_max_age | 200000000 > autovacuum_max_workers | 6 > autovacuum_multixact_freeze_max_age | 400000000 > autovacuum_naptime | 15s > autovacuum_vacuum_cost_delay | 20ms > autovacuum_vacuum_cost_limit | -1 > autovacuum_vacuum_scale_factor | 0.1 > autovacuum_vacuum_threshold | 25 > autovacuum_work_mem | -1 > > I have about 20 database with thousands of tuples (live and dead) but when I look at the pg_stat_user_tables within each database: > SELECT schemaname, relname, n_live_tup, n_dead_tup, last_autovacuum, last_analyze > FROM pg_stat_user_tables; > > all n_live_tups are 0 and all dead tups are 0, with null data for last_vacuum, and last_analyze which seems very odd to me. > > I can see there's live rows with select count and then I analyze a database, then I see live and dead tuples, and last_analyze shows the timestamp of when I just ran ANALYZE; > > Am I missing something here or is this abnormal behaviour? > > I'm also seeing my databases are above 90% towards hitting my autovacuum_max_freeze-age using this command. > SELECT freez, txns, ROUND(100*(txns/freez::float)) AS perc, datname > FROM (SELECT foo.freez::int, age(datfrozenxid) AS txns, datname. > FROM pg_database d JOIN (SELECT setting AS freez FROM pg_settings WHERE name = 'autovacuum_freeze_max_age') AS foo > ON (true) WHERE d.datallowconn) AS foo2 ORDER BY 3 DESC, 4 ASC; > > I also have looked for vacuum via ps -ef | grep vacuum but didn't get any return. > > And select * from pg_stat_progress_vacuum shows nothing as well. > > I shouldn't have to create cron jobs to run analyze and vacuum manually for each database, but I don't know how to further investigate this issue. > > Has anyone seen this before? Any advise would be greatly appreciated! Some ideas: - Did somebody run SELECT pg_stat_reset(); That would reset the statistics and explain that you see nothing in "pg_stat_user_tables". - After you ANALYZE the database, do you see something in "pg_stat_user_tables"? You should see something then. - Another explaination for the missing statistics could be a problem with the statistics collector process. Do you see and pertinent errors in the database log? If you restart the database, do you get errors from the statistics collector? Does a restart fix the problem? - Are the "track_activities" and "track_counts" parameters set to on? - Hitting 90% of autovacuum_freeze_max_age is no problem. It only means that you'll get some anti-wraparound autovacuums some time soon. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com