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 1hC7cE-0002sQ-FC for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Apr 2019 19:01:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hC7cD-0000Mh-4f for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Apr 2019 19:01:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hC7cC-0000Hs-Md for pgsql-hackers@lists.postgresql.org; Thu, 04 Apr 2019 19:01:32 +0000 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hC7c9-0000S7-NC for pgsql-hackers@postgresql.org; Thu, 04 Apr 2019 19:01:31 +0000 Received: by mail-qk1-x742.google.com with SMTP id k189so2366596qkc.0 for ; Thu, 04 Apr 2019 12:01:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=cz3jBRIZ7rMzuN/ATfB7P5seyHpbqZHsQUVIYud63l0=; b=qlR+sBiuz0sCfIEcQShtABhX0uv9sNQb5bgjq40pvW470nFzx+4ts9VVKmtAoaMsDa v6ximT1Im7aCvEdJGz1rre+85GypZNkxtshZ2DUoukt3LVVvjeXwGt1BLvhG0coE28Uc ABsomaWd1psktb46tgZycsLqjCNdLTQTDRl0sphI//SziMsmi1qWLRr6WpGsnJWJlgPo pV0WDkNZUmJcYXXYksT2RCSMvVqRHTatm7jmwiAGSIV3lAO4HGQkdmajhc1r8dzSjP0j 4OopEI94B9wSfAPm453MquBKjHsTcKC4uFJVVhY0nBCVLbspbonqPU5nPUiW5T8+Z1/P tuAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=cz3jBRIZ7rMzuN/ATfB7P5seyHpbqZHsQUVIYud63l0=; b=gJMFnfyoGUgtUxwGpfjmJJERsXNjBfGbqAdL9Yh2tj24E32G4oMSGaBxfH6BETFMPP IImpwPRHZUaCxLkB8WLCpa9iQCegbMfznbIP2npzL8JYPoq6UGUzLyFek+rFPslR9XE4 nN2n8SGxWhnouOkGE6qk9vqPhwpGe7SBPjaLw6BMwGgZWMUeGzJsU8Z0s+GqyUytDgUY rZuAC2Rzm+oPBJMHwOyZFxKeMsJaZNLMU2OwMZPNkVnTgDwwQ09FwvGtcEsw2t9DWMzG sFW67XlxMVq17PEGXN7wXXoXkx4sT4SGhhaJpRo/mlvI5CEZOqxXiJpwCEjPKfWBWzwI gqOw== X-Gm-Message-State: APjAAAWc+4jHlWtCi7vpDjK5QrKNTNyEYTZ5UwJVbCTtGxVLa9kayBRn Tmm0iiziI3J77zzpPQISczzdoA== X-Google-Smtp-Source: APXvYqwwZbxe5jlRZnC11L+0zLZx1tInORixHo81ffnCiaGBcaFl31Suf84QjZb/4bbJOG3Fur13hg== X-Received: by 2002:a05:620a:14bc:: with SMTP id x28mr6744990qkj.221.1554404488727; Thu, 04 Apr 2019 12:01:28 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id g5sm10651284qke.71.2019.04.04.12.01.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2019 12:01:28 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 3D2C8120F3B; Thu, 4 Apr 2019 16:01:26 -0300 (-03) Date: Thu, 4 Apr 2019 16:01:26 -0300 From: Alvaro Herrera To: Justin Pryzby Cc: Arthur Zakirov , pgsql-hackers@postgresql.org Subject: Re: query logging of prepared statements Message-ID: <20190404190126.GA6155@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190404182630.GA4305@alvherre.pgsql> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Apr-04, Alvaro Herrera wrote: > I think we could improve on this by setting a "logged" flag in the > portal; if the Parse logs the statement, then don't include the > statement in further lines, otherwise do. Also: I think such a flag could help the case of a query that takes long enough to execute to exceed the log_min_duration_statement, but not long enough to parse. Right now, log_min_duration_statement=500 shows 2019-04-04 15:59:39 -03 [6353-1] LOG: duration: 2002.298 ms execute 2019-04-04 15:59:39 -03 [6353-2] DETAIL: parameters: $1 = 'joe''s place' if I change the testlibpq3 query to be "SELECT * FROM test1 WHERE t = $1 and pg_sleep(1) is not null", Also, if you parse once and bind/execute many times, IMO the statement should be logged exactly once. I think you could that with the flag I propose. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services