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 1h4Ldt-0008Kb-CA for pgsql-performance@arkaria.postgresql.org; Thu, 14 Mar 2019 08:23:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h4Lds-0003ac-0b for pgsql-performance@arkaria.postgresql.org; Thu, 14 Mar 2019 08:23:08 +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 1h4Ldr-0003aU-G4 for pgsql-performance@lists.postgresql.org; Thu, 14 Mar 2019 08:23:07 +0000 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4Ldn-0001U8-Lo for pgsql-performance@lists.postgresql.org; Thu, 14 Mar 2019 08:23:05 +0000 Received: by mail-io1-xd31.google.com with SMTP id u12so4243188iop.11 for ; Thu, 14 Mar 2019 01:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=+cRJL+U+PRMhdYqZRLVRUFSu9VP45wpuL4uXGemRpus=; b=OVqPeMhOqZqItPThWUVoXT8jewVdb78WaAqiyYZ5WzVvWNS3t3scOcMaesS9tTNEOe j8oxJGHR2NozguvXwnf09VodJIdzBTW0+qG2Wj8xlwZNuOoWAEfCpgTEFJ9f6U3sIBPK 2GETE1b7MBYIvN1h+a/2opk7rPcjg0zy27sAlJYglu1cJcv+o1tJam6lxD0l3pqCBk9D V68fGiLx09fhFRsSaz7zHheWeFsgrRq2ycnorvSeHlou6LOGGuAmKykUtwl6k/9z3zXa 0aZ8Vh/D0myyaBzdSlK4vFGjvPHGKBdMhmQs8mFZTOiSeRZX4MAIxbOkNPOQdixprOSN Gz3Q== 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:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=+cRJL+U+PRMhdYqZRLVRUFSu9VP45wpuL4uXGemRpus=; b=To0z4rXEVYuIqrbGsWCk+PU5IRNGG5nNXA0Zyp59gzfm4bAqjefWoB+ytegjalUJL9 BSd5SxWFJxoNe1o5es8MKMsZenrtLcK3mcraY7eMT/vajuGRE3ZU+r7KKbU/hG7z9FCy dOpViZ/jpX8vsitjiDpvVUPcFI+XoZUlZpDTOpFFqba/l2Wp6Lp4qAvXJD5KrMgb52/D mIySAqxtDEIo1XVUQisyvaKsPCTEYDxezaPBOkWhvUXL+gC/avdUCG2nbKK+UYrMGeaC GrIU42PdA+nInXKwDFEyEdWmAB8ZlWYo1dcumYqAc2JaQttS18Na6gAwLv5PXVwCKQqP tT4A== X-Gm-Message-State: APjAAAXIHB9OrUaXeA1okInriv9cWgvDNR0Jf16QWdjM2L0CBLZA74yD sJEzIyWVlbjK94LUGxUOoTD8s2mUZd0= X-Google-Smtp-Source: APXvYqypPdAMrdEyfWgHEla09OYETRYqbiVGxRmbt5L79QRwK4lG6qwoDs4mXlhrMIRKy7ANw7/aWw== X-Received: by 2002:a6b:d304:: with SMTP id s4mr23047411iob.228.1552551782739; Thu, 14 Mar 2019 01:23:02 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id b137sm836869itc.39.2019.03.14.01.23.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Mar 2019 01:23:02 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id D640E80100A; Thu, 14 Mar 2019 03:23:00 -0500 (CDT) Date: Thu, 14 Mar 2019 03:23:00 -0500 From: Justin Pryzby To: Stephan Schmidt Cc: pgsql-performance@lists.postgresql.org Subject: Re: impact of auto explain on overall performance Message-ID: <20190314082300.GC6030@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.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Mar 14, 2019 at 07:29:17AM +0000, Stephan Schmidt wrote: > i’m currently working on a high Performance Database and want to make sure that whenever there are slow queries during regular operations i’ve got all Information about the query in my logs. So auto_explain come to mind, but the documentation explicitly states that it Comes at a cost. My Question is, how big is the latency added by auto_explain in percentage or ms ? https://www.postgresql.org/docs/current/auto-explain.html |log_analyze ... |When this parameter is on, per-plan-node timing occurs for all statements executed, whether or not they run long enough to actually get logged. This can have an extremely negative impact on performance. Turning off auto_explain.log_timing ameliorates the performance cost, at the price of obtaining less information. |auto_explain.log_timing (boolean) |auto_explain.log_timing controls whether per-node timing information is printed when an execution plan is logged; it's equivalent to the TIMING option of EXPLAIN. The overhead of repeatedly reading the system clock can slow down queries significantly on some systems, so it may be useful to set this parameter to off when only actual row counts, and not exact times, are needed. This parameter has no effect unless auto_explain.log_analyze is enabled. This parameter is on by default. Only superusers can change this setting. I believe the cost actually varies significantly with the type of plan "node", with "nested loops" incurring much higher overhead. I think you could compare using explain(analyze) vs explain(analyze,timing off). While you're at it, compare without explain at all. I suspect the overhead is inconsequential if you set log_timing=off and set log_min_duration such that only the slowest queries are logged. Then, you can manually run "explain (analyze,costs on)" on any problematic queries to avoid interfering with production clients. Justin