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 1wTyyZ-000sIr-2f for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jun 2026 09:30:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wTyyX-009eZT-1F for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jun 2026 09:30:25 +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 1wTyyX-009eZK-0I for pgsql-hackers@lists.postgresql.org; Mon, 01 Jun 2026 09:30:25 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wTyyU-00000000YV8-2YXt for pgsql-hackers@postgresql.org; Mon, 01 Jun 2026 09:30:23 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-490a765e68eso9492415e9.1 for ; Mon, 01 Jun 2026 02:30:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780306220; x=1780911020; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:cc:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=W8BYCRvgC2VckI1x0nOxvev1+eUNh2g0AuyUOgy9cOw=; b=S9fWb0MQ4GJhsNm/lsJuiCekP1i6j5l4QP8o6KdT+MbkLNPW7tHWhWvX9znUMXFsFs pV84vsqA0npkMOesaHcXbYGA/nJysKkE3Hk24dVzwe2V9c706QQDRt2o2JWeAcU+QVmZ AUqbz7zbvhVvCopEwaIumOaKjltrwqajY0Y6GSUFYwuhn9TCv8ODkXBZCdUEguX9VMyi dY6sHFhzWGRbO/WfdVJmsx1A57D1hPWOQa5yaHiM049pKiD5lP2XQxewRNos5KfW4rj3 L7QrC4Gp/h3DYoQbFlY2Z/0cwaORcmgkXydPFOLgwjPpTjE6XaoMzvoj2fNS7PwwN77F hxXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780306220; x=1780911020; h=content-transfer-encoding:in-reply-to:from:cc:content-language :references: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=W8BYCRvgC2VckI1x0nOxvev1+eUNh2g0AuyUOgy9cOw=; b=Ll1RIP4N/GXyNtk5oQQ0VeV94SACn2TiZDbiAr4tMjFEwlgwMWTZMUDrdrsw6fCszT th61UamEMPAwd5JvQSAXo1vYwn82Uj/OrPcYpDbejiXbXWyY8hexbKRUb1/Umm5NPUkw TEFoIuf+KhTeY239QzvVWwU8X6iIU27IyB/E8MP9HMUA4Kpwen96hXqj4LtKoY+TMy2t BCtEQft0BzJVretERBd8mPnUFon3RMLv0HtgXIV/ArU2hgVpiorak6ty3OQaQLGYjGyR gScQzOjXGv+nOWqx12jV/+1yBKYiE/zAspJqt6aWJs9Mc5pwQerbvrIuMmOFnLAX+v7I vJCQ== X-Gm-Message-State: AOJu0YxsABv7BS65QRktG4Dqqj7rc+nVCZSB8C14NlAw3pRAxa2wdD4G VFkrOqpXBtNbqur48kq/XLjI4fUzFn0lCgt4ji3nTqtMTau/b1407YSE X-Gm-Gg: Acq92OFtVu47CB8SYRp9JgOT/wi0Zo8Sc3GxvzrruOa7XuQG9WII0WCZ8vdza0fW/GA lXY0lCPMfMyIA/wwPrxT9zUASeU0JUPvwMY4m13H1UK1a3rMts2m+o9J1uElREmWE3KYQrKpDEJ yuw8cvjfqnIJ7ve+fSxu4vlNMx48kfnNNHBRCXOm4lRCrtZQGOoqfsVskuogW9B5AyZcfk82f8r rxc8oUCuLOQKyA3We86juAM3HDU0ic6jVLK+V++2W0HKzEfWCI3uWrDtfJmdFkNVyVfOon2ZPFi K6FKdYzJuqyGLmwNikVXD9FFrK4CxFHaC9+kUPAXrxnf9PE2FKhLj+o4igJ8a5PpKaWFUKsANL3 ZC8huWmwgVAKf15tmqNfYj63JhGPujsQVdirrlmn9A4G8PmYEdnTMKySSMdsNsUYWLPDd1mFULM Eji00PsRuqFa6gRGk77kCXzTKHBNuk5/jwnhhN0wl1rRMR X-Received: by 2002:a05:600c:348f:b0:48f:e230:c3fb with SMTP id 5b1f17b1804b1-490a2988e6dmr205992135e9.33.1780306219327; Mon, 01 Jun 2026 02:30:19 -0700 (PDT) Received: from [192.168.15.251] ([80.251.191.198]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4909d6f35f8sm210752425e9.13.2026.06.01.02.30.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jun 2026 02:30:18 -0700 (PDT) Message-ID: Date: Mon, 1 Jun 2026 11:30:17 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: hashjoins vs. Bloom filters (yet again) To: Tomas Vondra References: <5cd8c20c-14b5-4b0d-bedc-69bf714e87eb@vondra.me> Content-Language: en-US Cc: PostgreSQL Hackers , andrew@dunslane.net From: Andrei Lepikhov In-Reply-To: <5cd8c20c-14b5-4b0d-bedc-69bf714e87eb@vondra.me> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Postgres is still gaining ground in this area. It’s helpful to see how other databases handle these challenges. On 30/05/2026 02:55, Tomas Vondra wrote: > The patches got stuck mostly because deciding if it makes sense to > build/use the Bloom filter is somewhat hard. For cases where 100% of the > tuples have a match it's pointless - it's just pure cost, no benefit. > The regressions are relatively small, though (<10%). We ran into the same problem when trying to estimate the number of 'generated' NULLs on the nullable side. So, it makes sense to focus on the estimation method for 'unmatched' tuples as a separate task. > However, chances are the filter is too big. We can't get work_mem, the > join is already using that for the hash table etc. We can maybe use a > fraction of it, and that may not be enough to fit the "perfect" filter. > We could bail out and not use any Bloom filter at all, but that seems a > bit silly. Maybe we can't fit the 2% filter, but 5% of 10% would be OK? Looking at DuckDB’s code, using bloom filters during hash table construction solves this issue.