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.89) (envelope-from ) id 1i2ybu-0002LM-0N for pgsql-general@arkaria.postgresql.org; Wed, 28 Aug 2019 14:07:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i2ybr-0006mG-SR for pgsql-general@arkaria.postgresql.org; Wed, 28 Aug 2019 14:07:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i2ybr-0006m9-I4 for pgsql-general@lists.postgresql.org; Wed, 28 Aug 2019 14:07:39 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i2ybj-000119-4d for pgsql-general@postgresql.org; Wed, 28 Aug 2019 14:07:39 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id D4D7D21F16; Wed, 28 Aug 2019 10:07:27 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 28 Aug 2019 10:07:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=R tHC3jiZkQunVRXLPEGFj7Wy/G5YZcVgfZtyDwx/r/A=; b=Ic+3WXYfUyaqW7z7r 4osT3aOQQ8fHMpXUVseRPeCbK0qL8XJG10wpZK/ho/LrssKhT6gekZd1zf+NBvs6 qiAq7N+RIXinTMYnzr4hUNsJb2zMPP5SWyT6NvvqJsS5LVNEyCoUDXERNcl9c+Bd lmvNspPKFKsyzs2FzX+czlSHk0Z98EdalPjxCg26AsPUObgmxHAxNyaYM0PU0Omd sfxcngK4w3AmLW4fsRDbiA3TlIXE12MHYKa+PFUWCwLrDTuyT2RnnJUzjo4k5kTm ky3nxZicM7Wf4zTHPQ/lY0uE2PfrzbBqsY6y47f+a6D0NAFy9amMifPF4Pmx+4CF BC39g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=RtHC3jiZkQunVRXLPEGFj7Wy/G5YZcVgfZtyDwx/r /A=; b=oPeIsWsjZWJUKzvSbQmk35SLcjt9agAIVlIrhRWPZKcnXjU8j7F9u2YkG 5uewz1+5QjBBjYppdqCeONOXCBAKJD8A18eSscOhAINEw3wlAE8JIXn5wtEsvAhb v6lzF2a551Jbri0Ao14fe8lU2k2Rj5rvR/VTP6uU58XaeLfi8So6trCYD3M/3EI/ AqedBITneWT2twl0S0oCOO94CloXjpCemMbDmmcnC6e6Acf6r+3lL2Erp4+9NcgH cqFNaS5Ycv9LQn68PnSyHEIDPWbQ8alfpiRPLzIfSPpHedaWjNOIcoFCYQ47/i20 fA/UFrsA4s34b9v9lWiwX55JnMjHw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrudeitddgjeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucfkphepjedurddvuddvrdduhedtrddvtddvnecurfgrrhgrmhepmhgrihhlfhhr ohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmnecuvehluhhsth gvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.4] (unknown [71.212.150.202]) by mail.messagingengine.com (Postfix) with ESMTPA id BAB9C80059; Wed, 28 Aug 2019 10:07:26 -0400 (EDT) Subject: Re: How to log 'user time' in postgres logs To: francis picabia , pgsql-general@postgresql.org References: From: Adrian Klaver Message-ID: <94ac4f4a-452e-02cd-a91c-4db3afbd4a2b@aklaver.com> Date: Wed, 28 Aug 2019 07:07:26 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 8/28/19 5:36 AM, francis picabia wrote: > > Recently had a problem where autovacuum was accidentally left off > and the database took 6 seconds for every task from PHP. > I had no clue the database was the issue because I > had the minimal > > log_duration = on > log_line_prefix = '<%t>' > > With those settings all queries seen were roughly 1ms > > I need this log to show the true time it takes to get a result back. > > In the Linux world we have the time command which shows the user > time reflecting all overhead added up.  I'd like postgres to show > times like that and then if there are problems I can look further, > change logging details, etc.. > > I checked docs, googled,  and didn't see anything obvious. I'm having a hard time believing autovacuum was involved in this, given you say the queries took only 1ms on average. That would have been the part that would have been impacted by bloated tables/out-of-date statistics. Some questions: 1) How did you arrive at the 6 second figure? 2) Is the PHP application on the same server as the database? > > -- Adrian Klaver adrian.klaver@aklaver.com