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 1tbFuG-009GAd-FO for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Jan 2025 09:23:16 +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 1tbFuF-00D5Of-I8 for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Jan 2025 09:23:15 +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 1tbFuF-00D5OW-8m for pgsql-hackers@lists.postgresql.org; Fri, 24 Jan 2025 09:23:15 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tbFuD-001Etg-0T for pgsql-hackers@lists.postgresql.org; Fri, 24 Jan 2025 09:23:14 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2156e078563so26175265ad.2 for ; Fri, 24 Jan 2025 01:23:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737710592; x=1738315392; 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=5XP3606ZRI8VZ6EGFDq23VqEKYRxlXg+kzOYY4Tdx2k=; b=lk359yNSayAaBfRSn1A0c2AxW73h8SAkk8ZCezvf6MWrsa0/8emLw2Bd2ZlWx196E7 Cnp/wgVNygHszC0oSYmy2UGHW7ZnjIiTaJouSxvklzTO1gN8j/fduR0hTSvM5Zea9GJJ 3kNSTI50/Ujp9W+BvaMAiENYRTRlbaf4OQqWyQqo+kNgveBkBhLCPxwAUKFJQfSnUa3o 4Sef5LF9cPqI4lDpUlgkaTi1yvv1yZzNj57lCdjzxLS6k2x58wJmZjL0zumYQKDLmtap 8D2disDYbHVc9lb5M/J9ybZA8WDDyNjUf1Q+GoUPkZMggO8IiSocKZJKB7M6Cgl1BDNl 1wuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737710592; x=1738315392; 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=5XP3606ZRI8VZ6EGFDq23VqEKYRxlXg+kzOYY4Tdx2k=; b=uY8CDyyRvCHiKB9/7zUd5nkLVQZfMmP4b+ws4x/f6slHcdV8k0AEru1qoaq7ewICOx a/sHcZk2TmxEu/RsmjTym79it3j3ABsQayKz4dFW8c658Dqe7R+8pEM5Tv1wlktmzlVd IE658bZYsf2pphZLuWelU/67zoLIrU5jY0QT7P/oAIQ6T4wJZctyb60UQHX0mIT2Lehj KzIhf2xmXolsj50kaEdgUAUxCbUoBOTN1LLzmh4Nx60IAyFRepiKCxv87L9m7P77Sv+z nIEcChWXt6atqzmlR3p0F77BCHwtvjkT7WBTKKEpXpMM0dwh1KyucnNF6w87VSm08kwf D1vg== X-Forwarded-Encrypted: i=1; AJvYcCWpe3pZLF0DgSlXsrGZRNgywog/81wKIezBzylKLAd2rTrCA0qPZJvKcovFpoLpiI9bZcIGhK1WlygAg0+i@lists.postgresql.org X-Gm-Message-State: AOJu0YzN9epDqOFaxM17Z+V/cb8SLytb1bfwIJjyqQwm8Dqj1ZGzmO7X +ana1Zw4vDoRC2XBNteCkY2eqrvLIiRYF2YAzIWsZX/hn+ANO39l X-Gm-Gg: ASbGncssU0Zm7aSZORKXVTGZDwVM1/nnsxeypgHtd61UHObQaDFikm04o/wr6tKfTzJ F+bc0VXH3ODHhY/m9s4uYL1nPvdn9uNy/7AZxWiH/796PS3QG6XFLzZ3GqW5HymeMpljpTPnhlM TaGDm5yMVq+dgk2PF486iet/dFwbOgPAXhAcOu2g1hAtvfk6TA15F0ouYbHBzrlhceq6WXQ4Pw+ VoYyF6DkseGqeMc6xV+T/RId5K0VIUNw2kgYWLV3KjHS69so3jj2x/LO319iB8rtMCSGtKzP4nA sB6YgoPTs1J/jZ3xD4H/J0RlMUkWzxKeQeTXfRFS9hRdPfiqB1ap8LHi1Dk= X-Google-Smtp-Source: AGHT+IFTpVM0aEorS2U+Q3h9VeOiSDPjXZCzJ/bWsmbbY/diZs3PAMCvACNzGhhMzQYLe+jktheZgw== X-Received: by 2002:a05:6a20:2591:b0:1e1:e2d9:3f31 with SMTP id adf61e73a8af0-1eb2148df72mr40912416637.16.1737710592424; Fri, 24 Jan 2025 01:23:12 -0800 (PST) Received: from [10.10.20.106] (node-tzx.pool-101-109.dynamic.totinternet.net. [101.109.151.221]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72f8a763468sm1399693b3a.106.2025.01.24.01.23.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Jan 2025 01:23:11 -0800 (PST) Message-ID: <5fd9a3d8-8c4e-470a-9146-164a77c75f79@gmail.com> Date: Fri, 24 Jan 2025 16:23:08 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Optionally record Plan IDs to track plan changes for a query To: Lukas Fittl , PostgreSQL Hackers Cc: Marko M , Sami Imseih References: Content-Language: en-AU From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/3/25 03:46, Lukas Fittl wrote: > My overall perspective is that (1) is best done in-core to keep overhead > low, whilst (2) could be done outside of core (or merged with a future > pg_stat_statements) and is included here mainly for illustration purposes. Thank you for the patch and your attention to this issue! I am pleased with the export of the jumbling functions and their generalisation. I may not be close to the task monitoring area, but I utilise queryId and other tools to differ plan nodes inside extensions. Initially, like queryId serves as a class identifier for queries, plan_id identifies a class of nodes, not a single node. In the implementation provided here, nodes with the same hash can represent different subtrees. For example, JOIN(A, JOIN(B,C)) and JOIN(JOIN(B,C),A) may have the same ID. Moreover, I wonder if this version of plan_id reacts to the join level change. It appears that only a change of the join clause alters the plan_id hash value, which means you would end up with a single hash for very different plan nodes. Is that acceptable? To address this, we should consider the hashes of the left and right subtrees and the hashes of each subplan (especially in the case of Append). Overall, similar to discussions on queryId, various extensions may want different logic for generating plan_id (more or less unique guarantees, for example). Hence, it would be beneficial to separate this logic and allow extensions to provide different plan_ids. IMO, What we need is a 'List *ext' field in each of the Plan, Path, PlanStmt, and Query structures. Such 'ext' field may contain different stuff that extensions want to push without interference between them - specific plan_id as an example. Additionally, we could bridge the gap between the cloud of paths and the plan by adding a hook at the end of the create_plan_recurse routine. This may facilitate the transfer of information regarding optimiser decisions that could be influenced by an extension into the plan. -- regards, Andrei Lepikhov