Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tpTx3-006GMw-EN for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Mar 2025 15:12:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tpTx1-00HYhg-KU for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Mar 2025 15:12:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tpTx1-00HYhY-8Q for pgsql-hackers@lists.postgresql.org; Tue, 04 Mar 2025 15:12:55 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tpTwz-000vgf-1H for pgsql-hackers@lists.postgresql.org; Tue, 04 Mar 2025 15:12:54 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-43bcc85ba13so6518975e9.0 for ; Tue, 04 Mar 2025 07:12:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741101171; x=1741705971; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=YW24UFOn02pZEzLv8mTxNBNPjwWyK9vEW0cytXWN1CU=; b=WuEUnkgP7HQ8HIR4IRWsPyTYM3vp6CqrcHFk8HqDp9J66rgFfpvJn4a/MpZ4nlIa0X vQOojFva0W1HPFS+5hvyfWLay/uSfp/fHLcuni3ATlefLn1Jm5wWx8QibD4stzptKDT8 vYLvGhWt4T6HLJk8JiYTOpDh+RXTZ5a2X/kL0sRVD05Ql8Kgxa9ctxOX03I5Y1uTcsxx LG0Pfgi+6Nvw/WWnxYvbomBGuM7Nv87ku0yqBzcPRhkXmzKg3PJ5Ldcw41q/f/jXtPGr pmV9Fre/28IAJhrBWfM641ZsckW6uJbHXsG6MJ+mP6yp5d62zZHWzuxAkJSljv1r3foV nUaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741101171; x=1741705971; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YW24UFOn02pZEzLv8mTxNBNPjwWyK9vEW0cytXWN1CU=; b=LZnOsCpmozBsIlE0/Gb41MKfraEAsTw4gYWeY+oCpsQIBthkCyNLZV1fiB9CcHgF5Z FeWSRGCqHD7Y9CRvDRe1kZEbhwPmxkjkSOZNKsHrnnvpUZXzWFTcjkemQm/iqpuKgK++ SCG0u7CE5zSzu0jWUzuon2i7F99Bbv583W/ALnQw+ax4KsBRIaqepuAiDD/Dt9MU/Te+ yfDexztH+axpAR/3t/PsntkHMCyn+yjGhX+DEUu7DPnOcbZ3ZLgRN7+8UM8sfKx/Of+4 X1KxG3BVMTrjJDbTs2gseqiNZETVQ324WovoEElCCfChAapR6XmoNj7/p91AmYlzxGID 5h+Q== X-Gm-Message-State: AOJu0YzM4jA/kkSWaUZYk6J48aTtstrvZ7UiAxuaU/j1yTkyUQ6mAAxg WsUixPDdTV7VNC1PeXByuKTezZNlbIsmPRqTh2wh2AtUYOp4T8c84iBAM1HO X-Gm-Gg: ASbGnctTbtyd9ol4h8Om0/RbbBYCn1hmjHCgTwNhA1qyJtIjDxgqx+pHLdaQxHKfzAM mxvCYDmdTW6dynAIiDdxPSAy0SDbmvQMXxi6MH5wjp1ToAluIcUdo8bE6ugnSltNd2NywIT/TX5 +YLMfzD970dQMRz25OpwsSAkfj7PMp+JK6uvT9/eqBVpd4dZ3Ad+8QwSw03SQodrazhLFpNZKLQ 3WTZrrm79ieZNNuLpPhgVaKvoeN8zqPHKMmO5oM+mSJfAqCENvWbu98JPYvbLgAeOBy5KkzV/zs FJ6wB/+5rXxFiZDlvG9D6B+oC1/nmhvBhM+UbIN6KMrqnpTLQVYcyw== X-Google-Smtp-Source: AGHT+IFVF+qWkYlRQyhCT/k5y7S20gt5TttJl9kpG267ogRqAyXCW8X/eECQOnEDuNGqRJSNyXIZWg== X-Received: by 2002:a05:600c:3b24:b0:439:9496:17df with SMTP id 5b1f17b1804b1-43ba66fee15mr154065505e9.13.1741101171013; Tue, 04 Mar 2025 07:12:51 -0800 (PST) Received: from [172.20.10.4] ([77.211.4.186]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43bc447a0b3sm67265805e9.3.2025.03.04.07.12.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Mar 2025 07:12:50 -0800 (PST) Message-ID: Date: Tue, 4 Mar 2025 16:12:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: making EXPLAIN extensible To: Robert Haas Cc: PostgreSQL Hackers References: <754369a6-9017-4d5d-8fea-7768e5b94b0f@gmail.com> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 4/3/2025 15:23, Robert Haas wrote: > On Tue, Mar 4, 2025 at 8:56 AM Andrei Lepikhov wrote: >> Passing through the patches, I would say that changing the order of 0001 >> and 0002 would make them more independent. > > Hmm, I thought this order made sense, but I could reorder them if > there's some compelling reason to do so. If there's no particularly > compelling reason, it would be less work to commit them in this order. I have no compelling reason except avoiding adding/removing explain.h into the head of auto_explain.c and file_fdw.c > >> Also, I'm ok with the floating order of extension messages in the >> explain output. We get used to living with dependencies on extension >> load order (pg_stat_statements quite annoyingly impacts queryid, for >> example), and this issue should be solved generally, in my opinion. > > I've often thought that the solution to this class of problems could > be to have extensions not manipulate a hook variable directly, but > instead call a function to which they pass their callback function and > an integer priority. Then we could call hook functions in priority > order. One difficulty is that this requires extension authors to agree > on what the priority order should be. In some cases that might not be > too hard, but it isn't apparent how it would work here. > > IMHO, it's reasonable for the author of an EXPLAIN extension to say > "well, I see Robert already created an extension with an option called > DEBUG, so I will name my option TROUBLESHOOT," or something of that > sort. But if Robert gave the DEBUG hook priority 50, should I also > give my hook priority 50, or should I make it 40 or 25 or 1 or 100 or > what? Even if I know about all of the other extensions it's not really > clear what I should do. Actually, in this case, it feels like it would > be better if the user could control the ordering somehow, but I feel > like that might be over-engineering. I think the same way. It would be clearer for an observer to have a dependency on load order everywhere than different orders in different places with no strong guarantees. Also, I think this feature is quite close to the discussion on the possibility of adding an extensible list field into Query, PlanState, Plan, etc. nodes to let extensions gather and transfer some additional data starting with the first 'analyze' hook up to the end of execution. For example, in solving user issues, I frequently need to know predictions on the number of groups in Memoize, IncrementalSort and some other nodes. Such extensibility could allow an extension to gather such internal data during the planning stage and show it in the explain without any changes in the core! -- regards, Andrei Lepikhov