Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a9Hvl-00076B-1J for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Dec 2015 19:40:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a9Hvk-0006Ox-Jq for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Dec 2015 19:40:08 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a9Hvj-0006OW-Tn for pgsql-hackers@postgresql.org; Wed, 16 Dec 2015 19:40:08 +0000 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1a9Hvg-00059h-QC for pgsql-hackers@postgresql.org; Wed, 16 Dec 2015 19:40:06 +0000 Received: by mail-wm0-x233.google.com with SMTP id l126so55269863wml.1 for ; Wed, 16 Dec 2015 11:40:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=+fEJhNXdoNif/XCkTCU18Ab3oJ31U/Vr5DyxS4cvzb8=; b=bUlbVj5TYINe2enfQfUX+51R9HmqTAR0VJ4+a5i91X+4/tP/qH1Ha/huO1CaehsnPc i0sYSqJtA7/S9KMDU9HxikSlQIXdG/bECyi+s+nwuruPOnKBpFz1pybZRoYTyQqnUd13 TPLCPg8htZbOGuETPrrbnzHS1cz49SGvYTQeJyiAbT0LVjej4MXBcyfiljWqNZkE5BML QaykUfdGToJBZCj+vjK00j4EmkhLwj7k7OSkiFP1d1vOtjehq+KLJBkZKc2w6OTM6eX7 srevbERMFpaE5uRnoBTtpOGK0y/CNri8D+hsTTfSEDAMzB1aRpifJN0YXGRC0Z+lIn/9 K49w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=+fEJhNXdoNif/XCkTCU18Ab3oJ31U/Vr5DyxS4cvzb8=; b=P16tm8/hkEIE5wcffV/K9udjR9VwK3+C+7U5n3foJhE3Uc3IY4Hrh6PNvrfXF+B14p 8uO2G2kNXlo/PaGy0N4ClGwOOWstrnp5dw2nl5DxgNlsX8JiNqQwSVTLEc0EaVvwMEGw B75cc/j38pvOyOGYbFD+j8Q1tCiNj9jMOl5vJuFew/cP1/QKMW14wUcciqFub9HDFtaU LQyaElryKhirT72+FFxlORBl5LwBWd89xfDZYjdJDERESLvb3qAwO4OWrA7q57VZXOij AAnOGQ2X1kXaHVS718XZINWJP98xKtyXpdlXwWY3oPauzjy62sH5Ybf0nSwAZCFRjwlV 8bRQ== X-Gm-Message-State: ALoCoQndlEG6cNY6thSfHUiXxdvR0WdCMw5P/htlbAOFGT1lrM9C7OUeRZc2xm3wBvgPKT/jH77wAFU9nHTA/5prsURkwaphsmAsmtwxftO05Dx0S5vU+U1WaU+SMel6glxZxQSGgLC8jQaHcRkMPXl9aqKge7ZowiEGQ5/PYHkO8rKsQ09t18vaOqUY5mKoVzH1E0gPPkUSk6w9gyd+g6ALdFX6tbkDuw== X-Received: by 10.28.183.215 with SMTP id h206mr14662133wmf.0.1450294802008; Wed, 16 Dec 2015 11:40:02 -0800 (PST) Received: from [10.137.1.13] (ip-78-45-216-26.net.upcbroadband.cz. [78.45.216.26]) by smtp.gmail.com with ESMTPSA id u62sm10265822wmg.4.2015.12.16.11.40.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Dec 2015 11:40:01 -0800 (PST) Subject: Re: On-demand running query plans using auto_explain and signals To: "Shulgin, Oleksandr" , Simon Riggs References: <32603.1444916567@sss.pgh.pa.us> <565CBF3C.7080106@dalibo.com> Cc: Julien Rouhaud , Pavel Stehule , Tom Lane , Robert Haas , PostgreSQL Hackers From: Tomas Vondra Message-ID: <5671BE0E.3040200@2ndquadrant.com> Date: Wed, 16 Dec 2015 20:39:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Hi, On 12/01/2015 10:34 AM, Shulgin, Oleksandr wrote: > > I have the plans to make something from this on top of > pg_stat_statements and auto_explain, as I've mentioned last time. The > next iteration will be based on the two latest patches above, so it > still makes sense to review them. > > As for EXPLAIN ANALYZE support, it will require changes to core, but > this can be done separately. I'm re-reading the thread, and I have to admit I'm utterly confused what is the current plan, what features it's supposed to provide and whether it will solve the use case I'm most interested in. Oleksandr, could you please post a summary explaining that? My use case for this functionality is debugging of long-running queries, particularly getting EXPLAIN ANALYZE for them. In such cases I either can't run the EXPLAIN ANALYZE manually because it will either run forever (just like the query) and may not be the same (e.g. due to recent ANALYZE). So we need to extract the data from the process executing the query. I'm not essentially opposed to doing this in an extension (better an extension than nothing), but I don't quite see how you could to do that from pg_stat_statements or auto_explain. AFAIK both extensions merely use hooks before/after the executor, and therefore can't do anything in between (while the query is actually running). Perhaps you don't intend to solve this particular use case? Which use cases are you aiming to solve, then? Could you explain? Maybe all we need to do is add another hook somewhere in the executor, and push the explain analyze into pg_stat_statements once in a while, entirely eliminating the need for inter-process communication (signals, queues, ...). I'm pretty sure we don't need this for "short" queries, because in those cases we have other means to get the explain analyze (e.g. running the query again or auto_explain). So I can imagine having a rather high threshold (say, 60 seconds or even more), and we'd only push the explain analyze after crossing it. And then we'd only update it once in a while - say, again every 60 seconds. Of course, this might be configurable by two GUCs: pg_stat_statements.explain_analyze_threshold = 60 # -1 is "off" pg_stat_statements.explain_analyze_refresh = 60 FWIW I'd still prefer having "EXPLAIN ANALYZE" in core, but better this than nothing. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers