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 1nuFzL-0001Ds-O2 for pgsql-performance@arkaria.postgresql.org; Thu, 26 May 2022 16:05:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nuFzK-0006CZ-Ip for pgsql-performance@arkaria.postgresql.org; Thu, 26 May 2022 16:05:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nuFzK-0006CQ-8q for pgsql-performance@lists.postgresql.org; Thu, 26 May 2022 16:05:26 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nuFzH-0000iZ-9p for pgsql-performance@lists.postgresql.org; Thu, 26 May 2022 16:05:25 +0000 Received: by mail-io1-xd2f.google.com with SMTP id y8so1976113iof.10 for ; Thu, 26 May 2022 09:05:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=7qJgpiSNugeTaK78rBSU5pDlHiX2F+fzCiqqkRKxTo4=; b=BkOrFFZwkTAIZEJb4RONJO0Eqy0kIaQFVbGqXHLXIrXF0Ny5JonYQDIg+D4qUf68bj wYGwcKwzVVSbgL24vG7HpvY+5S790gdSXMaEQ5Q0lo5nYQvRs+da68x+u9GuF2c/kM/O /zy+CvPrrSKLxCdZ6cDHiY2YwEUXbh5jpEI8q05YgIxZxyEkDAkgRApDv/2AX17JHwh6 UseNpx1ZCMYeRitOLOAMjFJJEzDDQ61QsBvsEKc62oUnj941gWKkvv4xh5Xvkryae2B5 GhZogvRizjcHne905sUZA5rl2dmuIGoWqk6R1TxxGAin4yIk/NnWwiaP1BazcV0uBC1I Mz4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=7qJgpiSNugeTaK78rBSU5pDlHiX2F+fzCiqqkRKxTo4=; b=XaOmoxPr574AUL/m0RcGR6ub8ninKq+D9aff+VGTfEQz9x+FiS6lHVZnh9yMtIP0U2 PPQqqyeHGM0qy1I5eLSsQMwLnkRQroll7iyTM3QoLaTHmryNW6Q+CVTbLaM/VJOYmC57 WUsV+S+TnClrzAD4DKG3nsEPWsd9Kqfv8CQGAzwmKOueg4bPPXzWlwWGfksPqonQj5HL 2Cr0Z7safBF2Dp4pDMB/j8tc8jswa/rCQTuiGAf0l2DK2V/x7ODBWlxSYwMQZ9nv1+6Y hnnc0QYwWGYRLvLbvzbGSpb+KFZcUT+JBuW9b9LEQLbM7nhQDCLYt59B2z8WoxMuYfsY TN9A== X-Gm-Message-State: AOAM533peut+JiH+Msu6ahz5GlD/Qtlmv2ZfZ8nohIZ1zubziaieQpwq TcIMfB32vzviQvdbxM6oj9P1GQ== X-Google-Smtp-Source: ABdhPJy+lnm/TIfn0DBc9IT0uWd7gXWoQH02Hci1yJHtnCC5s4FsFSlpEEjMckO4vDorhJjIaAmXBg== X-Received: by 2002:a02:b893:0:b0:32d:c698:1a3a with SMTP id p19-20020a02b893000000b0032dc6981a3amr18710255jam.51.1653581121495; Thu, 26 May 2022 09:05:21 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id z6-20020a056638214600b0032b3a781781sm495907jaj.69.2022.05.26.09.05.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 May 2022 09:05:21 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 0E7A78008F8; Thu, 26 May 2022 11:05:20 -0500 (CDT) Date: Thu, 26 May 2022 11:05:19 -0500 From: Justin Pryzby To: =?utf-8?B?5b6Q5b+X5a6H5b6Q?= Cc: pgsql-performance@lists.postgresql.org Subject: Re: How to monitor Postgres real memory usage Message-ID: <20220526160519.GB19626@telsasoft.com> References: <20220524174050.GI19626@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > enable_seqscan = 'off' Why is this here ? I think when people set this, it's because they "want to use more index scans to make things faster". But index scans aren't necessarily faster, and this tries to force their use even when it will be slower. It's better to address the queries that are slow (or encourage index scans by decreasing random_page_cost). > maintenance_work_mem = '64MB' > autovacuum_max_workers = '20' > vacuum_cost_limit = '2000' > autovacuum_vacuum_scale_factor = '0.0002' > autovacuum_analyze_scale_factor = '0.00001' This means you're going to use up to 20 processes simultaneously running vacuum (each of which may use 64MB memory). What kind of storage does the server have? Can it support 20 background processes reading from disk, in addition to other processs ? Justin Pryzby 于2022年5月25日周三 01:40写道: > > What postgres version ? > > How was it installed ? From souce? From a package ? What about this ? I'm not sure how/if this would affect memory allocation, but if the server is slow, processes will be waiting longer, rather than completing quickly, and using their RAM for a longer period... Does the postgres user have any rlimits set ? Check: ps -fu postgres # then: sudo cat /proc/2948/limits