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 1k0Eod-0007HO-O2 for pgsql-general@arkaria.postgresql.org; Tue, 28 Jul 2020 01:54:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k0Eoc-0007Os-EM for pgsql-general@arkaria.postgresql.org; Tue, 28 Jul 2020 01:54:02 +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 1k0Eoc-0007Ol-1u for pgsql-general@lists.postgresql.org; Tue, 28 Jul 2020 01:54:02 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k0EoV-0001iX-BB for pgsql-general@lists.postgresql.org; Tue, 28 Jul 2020 01:54:00 +0000 Received: by mail-pg1-x542.google.com with SMTP id g67so11002238pgc.8 for ; Mon, 27 Jul 2020 18:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=XFAC+gKkm/iJiz3at3IE6cNGKhgdFr3tKt2BCbXxz2I=; b=b0sL0iLel0ApUNvWW7aeoac0Zzl4aeeuuOT97x53EEBEZn+6P6onu2Vd/rbbfgBpp+ o+K0BUA0JUrytX6kgree0/DL3oCx9eY9AOp4eSvGAJmSvy0CLIT7azjHBg8BvPQXp8G5 hLsx/BS/yGSnByDogvtgG4CC33NLgnb7p54Svxevyp5mGZ6vGDqoB1n0sgpB94kREHNV oMN2+Ug1ZK7L0YqgDu+wcurtHcSR+SIYffQByOte13KOH+JwD2YZqki6KTIsbi//mbPq rlKOUSPWKQYcN7rfYfWKzfmVS5PrFWjGGn3Zt97JmTqwDq+hoS/thQFJ4f6LDrp3dIyj IGvA== 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-language :content-transfer-encoding; bh=XFAC+gKkm/iJiz3at3IE6cNGKhgdFr3tKt2BCbXxz2I=; b=Q8asFb0aGUt/XI+6+b9ahxO9SI9FBJ9/h3DnmFvVTbYD8b+2NT/EJEpGD/jnCrN0aR PzEpeigzFDCVVurkwXiO+nBihqx1K9gmQitfGSXMMF734izkgXmt0QmsN0CV2htlfIdU wU0hHH/WEimnX53YUBcJjGI7TqXQk197+l/6CrjI9FRKmp3rlCHjUh5Lj29OcKbhj5rW 9aBTSuIHLIjB+u1XrAIRkPHB8FM1KgIFamx3tihqfBhGO/33xPfTytEQm+IzTTuYaWaN inVTTVKGhMfcb58po9Dby0KFjiGtmNMGhqLPzgJq8bDDaRU+jVeRB6dAh0TqK1qN84AH A14A== X-Gm-Message-State: AOAM531H+p6+THxcop+M7FvNjYWu3JWmDOyHWiNwkE7293fjahhtm5EO 4PmyE2yBBhm2KzXUrc7s4Vu3H5fImTNDy8WNY0iYNU9chjSrYvb8fOCIDBkAb74HDsn89b9rqqJ 6di4dKnZQNFL6N5+bk1QPjFGrUUdTz4OFGvnWX+T3I9+LSfVX1PPbx1LUHT/rtEcin50zvOTbgB pPflrbVFY/KHjyJL+ekW6ONyU= X-Google-Smtp-Source: ABdhPJwWiyKHAo5CisIZ1koyrpLgNSCT/rYKup5VBwdT5i6vV0U5q2a/AAEdvW60TcRSrPJi36PC8w== X-Received: by 2002:a63:457:: with SMTP id 84mr22787130pge.219.1595901233957; Mon, 27 Jul 2020 18:53:53 -0700 (PDT) Received: from osaka.octopusnet (p8286141-ipngn43701marunouchi.tokyo.ocn.ne.jp. [180.34.70.141]) by smtp.gmail.com with ESMTPSA id b8sm914665pjd.5.2020.07.27.18.53.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 Jul 2020 18:53:52 -0700 (PDT) Subject: Re: postgres stats on the new primary To: Ayub M , pgsql-general@lists.postgresql.org References: From: Ian Barwick Message-ID: <94734afa-1110-900e-a8a9-51a1219e14a8@2ndquadrant.com> Date: Tue, 28 Jul 2020 10:53:49 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020/07/28 9:08, Ayub M wrote: > I have a RDS PostgreSQL v11.6 with primary and standby. On the primary, vacuum/analyze > were running and pg_stat_all_tables's last_vacuum/analyze/autovacuum/autoanalyze > were having values when vacuum/analyze were run. > > 1. Switchover to Standby happened, now when I see pg_stat_all_tables (on the active > primary which was standby earlier), the last vacuum/analyze columns are all nulls. > Would primary-standby replication not replicate system tables? Is this how it behaves? The information shown by the various pg_stat_* views is specific to the local server, and is *not* replicated. In most cases that wouldn't even make sense. The information is collated by the statistics collector [1] and is stored in memory and/or files in the data directory, not as a system table. [1] https://www.postgresql.org/docs/current/monitoring-stats.html > 2. On the new primary, would the table have stats on them? (I do see pg_stats > entries for the tables on new standby), are they reliable or do I need to gather > stats and run vacuum after failover/switchover to standby? The statistics about the *contents* of the database, as shown by pg_stats, are of course replicated and will be reliable. More precisely they'll be as up-to-date as the last vacuum/analyze on the former primary, just you won't see the information about when that was. Regards Ian Barwick -- Ian Barwick https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services