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 1mEBrD-0008NK-G8 for pgsql-general@arkaria.postgresql.org; Thu, 12 Aug 2021 14:38:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mEBrC-00066Y-G7 for pgsql-general@arkaria.postgresql.org; Thu, 12 Aug 2021 14:38:54 +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 1mEBrC-00066Q-6J for pgsql-general@lists.postgresql.org; Thu, 12 Aug 2021 14:38:54 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mEBrA-0002ED-70 for pgsql-general@lists.postgresql.org; Thu, 12 Aug 2021 14:38:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Type:MIME-Version:References:Reply-To: Message-ID:Subject:Cc:To:Sender:From:Date:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=hVajK9WdsNNIYyd0tSTTVigiOTqK+hhFOgu+dXyCDL8=; b=tCyeVM4F1Ag3mFiaA79Taa7AHC mxak+K/KhApXgQDIovmqBsMMSDIenNyHiAFvtQIEKhQlcaVCJ/LzTLLkSZXbgUiM7oUshRrMP4i2Q KmMtVb2SdqV1grVdns+1OzXc1HMtPTuPIT+94KPHXfnb460BLEMQt6a87ksJF6LLtufc=; Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by depesz.com with esmtpa (Exim 4.92) (envelope-from ) id 1mEBr7-00037C-Nx; Thu, 12 Aug 2021 16:38:49 +0200 Date: Thu, 12 Aug 2021 16:38:49 +0200 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: Magnus Hagander Cc: Alvaro Herrera , pgsql-general Subject: Re: Getting pg_stat_database data takes significant time Message-ID: <20210812143849.GB9497@depesz.com> Reply-To: depesz@depesz.com References: <20210811131247.GA27197@depesz.com> <202108111416.4ddlilf6hr6r@alvherre.pgsql> <20210811163355.GA20926@depesz.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Aug 12, 2021 at 11:32:15AM +0200, Magnus Hagander wrote: > Which database are you connected to? If you just want to look at the > global stats, it might help to be connected to a database that is > *not* the one with all the tables in -- e.g. connect to "postgres" and > query pg_stat_database looking for values on a different database? In > this case it would open files for "global", for "database postgres" > and "shared relations" only and skip the file for your db with many > objects. I think. I'm connected to the db I need data about, and I need data from virtualy all columns of pg_stat_database. depesz