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 1ntYWk-00047j-1W for pgsql-performance@arkaria.postgresql.org; Tue, 24 May 2022 17:41:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ntYWi-0006SY-Fb for pgsql-performance@arkaria.postgresql.org; Tue, 24 May 2022 17:41:00 +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 1ntYWi-0006SN-38 for pgsql-performance@lists.postgresql.org; Tue, 24 May 2022 17:41:00 +0000 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ntYWa-000738-R4 for pgsql-performance@lists.postgresql.org; Tue, 24 May 2022 17:40:59 +0000 Received: by mail-qk1-x72d.google.com with SMTP id i68so14333844qke.11 for ; Tue, 24 May 2022 10:40:52 -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=vqVFR+XCeEEMdCZ6Fgisn0Y767UctQSPT1G2HPhzP4U=; b=1/hag3PVU75IgV0CFVuZ4sXRhJ+1bNq2h6qtU5UiRW2IbpsnRWkwJIT0pF3FkqmPg9 wMjfeET+wrmFUsRwVVGtbI8tnUkfBQZFQqqSHlquhkTQU6MyzA3CPx8xTUwVJOnTbQtB Gg4Rab9fPlToZiJreiGY43OyrVCg2In/bCXxWCAKn4JoTau1O6CryxsuZ0O23f7UGGyc ug9TFz4NQru+Msw6/eSeNCCIUOEzFb0IukxSZN4h8p59o6+NjV/BdmCnZpY9mNcngDw3 qJnxVTw+6+W8RcxLG1PLoYk3e3C0UGQF99A9uTAx9zRRCA7XtEhcspLSCwdm8q45iUaY oy/w== 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=vqVFR+XCeEEMdCZ6Fgisn0Y767UctQSPT1G2HPhzP4U=; b=kEzsBH0grP83U4Tsflo5gaicLktnyqcGNqeQ1P875e+fcjc4B0Pm9L2MIXqZzP+Hos tWdfK0ed3t20qck/TvAgHmz9XmQhPvdqcxGnIGPF/rvBw98ia/EpoGwlHoSuTnfh0y+U EDrn1J38WH4s7+eZxljiVy5T6DGtrfi+VC/dnJdW30ALi0BIbs/BWHt0gfxSOKNeg0kW tACPKeQAQl+w91KXSLjTVf4IOCVRu+iqlK+3sHBYwNBmPquiG++xnCFTj8JrfQFlMibu 3BXmqvWSZdI8+9VV4ElBO062Oef/JgKWi2wUXAaTjgA7HIXqXNFDgfMIO1CJUTTSqWZD lH6Q== X-Gm-Message-State: AOAM531jNJP0P5yRgP3EiqIT256lysqxVdlbA5OOyYhhh8IjwzAg6bqj g7Z0SKyxVs97C6H9rXHlJYCabA== X-Google-Smtp-Source: ABdhPJzydKr5gEcvlTKIuabOVQFPGG7kotRyydQGuZ7zhsvZ57SOh6bUnfp5QvbKKUnbLQWlWug87Q== X-Received: by 2002:a37:cd3:0:b0:6a3:2587:6dc4 with SMTP id 202-20020a370cd3000000b006a325876dc4mr17466659qkm.454.1653414051772; Tue, 24 May 2022 10:40:51 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id w7-20020ac843c7000000b002f939be4868sm3225011qtn.19.2022.05.24.10.40.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 May 2022 10:40:51 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 7BBE0800785; Tue, 24 May 2022 12:40:50 -0500 (CDT) Date: Tue, 24 May 2022 12:40:50 -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: <20220524174050.GI19626@telsasoft.com> References: 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 On Wed, May 25, 2022 at 12:25:28AM +0800, 徐志宇徐 wrote: > Hi All > > I am a Database DBA. I focus on PostgreSQL and DB2. > Recently. I experience some memory issue. The postgres unable allocate > memory. I don't know how to monitor Postgres memory usage. Postgres is just an OS Process, so should be monitored like any other. What OS are you using ? Know that the OS may attribute "shared buffers" to different processes, or multiple processes. > This server have 16G memory. On that time. The free command display only 3 > G memory used. The share_buffers almost 6G. > > On that time. The server have 100 active applications. > New connection failed. I have to kill some application by os command "kill -9" It's almost always a bad idea to kill postgres with kill -9. > The checkpoint command execute very slow. almost need 5-10 seconds. Do you mean an interactive checkpoint command ? Or logs from log_checkpoint ? > Is there any useful command to summary PostgreSQL memory usage ? You can check memory use of an individual query with "explain (analyze,buffers) .." https://wiki.postgresql.org/wiki/Slow_Query_Questions What settings have you used in postgres ? https://wiki.postgresql.org/wiki/Server_Configuration What postgres version ? How was it installed ? From souce? From a package ? -- Justin