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.96) (envelope-from ) id 1vm906-0083TC-2m for pgsql-hackers@arkaria.postgresql.org; Sat, 31 Jan 2026 11:18:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vm904-007vCE-2K for pgsql-hackers@arkaria.postgresql.org; Sat, 31 Jan 2026 11:18:49 +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.96) (envelope-from ) id 1vm904-007vC6-17 for pgsql-hackers@lists.postgresql.org; Sat, 31 Jan 2026 11:18:49 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vm902-000Jji-3C for pgsql-hackers@lists.postgresql.org; Sat, 31 Jan 2026 11:18:48 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4806fbc6bf3so30593395e9.2 for ; Sat, 31 Jan 2026 03:18:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769858326; x=1770463126; 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=TmH/xKRR8bQOhrAep7MdsJVE3NFU9D8xjtPYOTohH3Y=; b=ZtfP7n8bK3IHPX1maxcJg+RdbBinvErZ6BY2W2fSKOTXUzVRTUXJvWbkZx1A8kgvpI RjQMse/Vg0oTJE/ikaHXyNCKcl8x68d9D8GfEInHyN3YF1urRYLt5pnT+aHs6oCvBVkj 1sX8GNU8E8F+f0RUTuedkXVrKW/hKRizxzFogiRFRSuXoV9q81ME4s//Q2Xx2ujal7jT zinLwua9eXFs9E2gQ/MtPRI5d9ZrzZR/WO7pB7QKyZFiHnZis2ChoRVUdoy2QeKEhKvJ 400ZbINQ1gLX+RS+uxwLh8Hiw9payP5Wf39S15yC45HdCg6Gvpysb+3Hlw0UOEpUlluB /QRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769858326; x=1770463126; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TmH/xKRR8bQOhrAep7MdsJVE3NFU9D8xjtPYOTohH3Y=; b=D9oM7atJEuuZpnyYZsJwRCWH36emhLNuBDzqasiQX/8o8v0Kgz9C3bSOGxoV7sQigb iynP/e0Bi3tR4bAIrOBeEuM0tqjkppta7lTnWQ4ndMdm80npmy92VrrTnXhwFaE6lv0P 7IaDJVO9lVNhaW5Ozajc8arlU18Z4KEf08Cu6+C8QTeVrOHlHnvvNmaViMSZNXyw/oRz ie/rx7j3RzCubINePCK/o6oo8+0JbUx94xomuEiDO1jrEwyfA2iuJWphQUtPqjXihBWE kkwfQ1ZM/EWrI4lYqfTzHZ9J3cFVH83iJuQuwu8VHlIyB0+nyP6jmha134wd/DfPzcS5 kPjQ== X-Forwarded-Encrypted: i=1; AJvYcCXBEcpOb8TZJnDiwEH7ZvbKwaQKzsN9QpSPfYGso1mvucqZiv1qQDiPIi3SoS7sebglGvG3cue0FcZqpCPo@lists.postgresql.org X-Gm-Message-State: AOJu0YwoXuwitjyviNW/xyMnqHkunGxSdooqKBPUklBRPlQN2QLFGuYo GMpNyCDgJ4z3wdq2oGBfwxS74SBrDjGalsSP1PUT6UX0lkjQad2Do0kN X-Gm-Gg: AZuq6aKvyvfLvRg5UJgr4vBZpRiXJv6LqFAgb6so2LH639BFN4YEHdwodJQJig8QdtX JRCsZCz+IkisR+a5WIWOHNFI+FWRnASnxVCrhbcIH2CHV+ank/w1Jn6AsPdJKI4tXISP4mXGQop D5MuxczfTY9BfvzlnzJiuGKM5SnKudxOdDlA4ch9j9DoLAw7H49lmmFsh5KD/8P0Si9jw2Bg1iy P1CLY4IzPi4yfrd9i1NGUdZIaCXTRSL+hcM//0qhEk9QdHHrKF9nl0pWahUylyAiybgDXIU6CBu K0k2I1kA61gZ1CB9Um+8S8VOh5bVloqaprh8gZl5B4sbIKhhRTf0tqo0jTiYYC43szuTJmnDUAj W/Op5n3WqhlhODNE07wq5oQFHmVBpj61gvEwYFx9si/+EjfRNQ8qgiFeLO/m6feMClKbxj7qOvg M5Ki6ugj8XhjUc2tPXY7DKgDuU0Q== X-Received: by 2002:a05:600c:64c6:b0:477:5ad9:6df1 with SMTP id 5b1f17b1804b1-482db4593a1mr72571595e9.3.1769858325924; Sat, 31 Jan 2026 03:18:45 -0800 (PST) Received: from [192.168.15.247] ([80.251.191.198]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-482dbd0f043sm48366155e9.7.2026.01.31.03.18.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 31 Jan 2026 03:18:45 -0800 (PST) Message-ID: <8df3d212-5d60-4e30-9606-d8849f7d37ae@gmail.com> Date: Sat, 31 Jan 2026 12:18:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Is there value in having optimizer stats for joins/foreignkeys? To: Alexandra Wang , Corey Huinker Cc: Tom Lane , Tomas Vondra , pgsql-hackers@lists.postgresql.org, hs@cybertec.at, Jeff Davis References: <246035.1764627115@sss.pgh.pa.us> Content-Language: en-US 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 29/1/26 06:04, Alexandra Wang wrote: > Hi hackers, > > As promised in my previous email, I'm sharing a proof-of-concept patch > exploring join statistics for correlated columns across relations. > This is a POC at this point, but I hope the performance numbers below > give a better idea of both the potential usefulness of join statistics > and the complexity of implementing them. I wonder why you chose the JOIN operator only? It seems to me that any relational operator produces relational output that can be treated as a table. The extended statistics code may be adopted to such relations. I think it may be a VIEW that you can declare (manually or automatically) and allow Postgres to build statistics on this 'virtual' table. So, the main focus may shift to the question: how to provably match a query subtree to a specific statistic. -- regards, Andrei Lepikhov, pgEdge