Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oeA9T-0002eX-Or for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Sep 2022 07:09:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oeA9Q-00065I-MG for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Sep 2022 07:09:36 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oeA9Q-000658-AN for pgsql-hackers@lists.postgresql.org; Fri, 30 Sep 2022 07:09:36 +0000 Received: from mx.zeyos.com ([88.99.153.70]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oeA9N-000235-Ty for pgsql-hackers@lists.postgresql.org; Fri, 30 Sep 2022 07:09:35 +0000 Received: from mx.zeyos.com (localhost [127.0.0.1]) by mx.zeyos.com (Postfix) with ESMTP id 6F644619FB for ; Fri, 30 Sep 2022 09:09:31 +0200 (CEST) Authentication-Results: mx.zeyos.com (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=zeyos.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zeyos.com; h= content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:to:from:from:subject:subject :date:date; s=dkim; t=1664521771; x=1665385772; bh=lV3Fd3y//0NwF IqEOM+Y1yOHpoGM/ue1TRtAjqauvas=; b=wEYta+nNKvSr3AyCohXt+1FhHyr2O pbjKy11hkU5py/zuGgk3gBWRqfP5gc93GSAEy+zpRYWI3Pp78kfIclvfceC/Owyd gdXhMiFGoDZc9H6uHktLgRwnPkCBmrllU/nF0fmH1VAIoNCCh1l3kgTlvyqXV/TP tA7IH0Zayg5ICA= X-Virus-Scanned: Debian amavisd-new at mx.zeyos.com Received: from mx.zeyos.com ([127.0.0.1]) by mx.zeyos.com (mx.zeyos.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 6eOKLusbesQG for ; Fri, 30 Sep 2022 09:09:31 +0200 (CEST) Received: from cloud.zeyos.com (static.182.82.88.23.clients.your-server.de [23.88.82.182]) by mx.zeyos.com (Postfix) with ESMTPSA id EC3E7619E0; Fri, 30 Sep 2022 09:09:30 +0200 (CEST) Date: Fri, 30 Sep 2022 09:09:30 +0200 Subject: Re: disfavoring unparameterized nested loops From: Benjamin Coutu To: Tom Lane , Bruce Momjian Cc: Peter Geoghegan , PostgreSQL Hackers , Robert Haas , David Rowley Message-ID: <96dbbf5d33fa97dc4c1f@zeyos.com> In-Reply-To: <482086.1664495178@sss.pgh.pa.us> References: <482086.1664495178@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > Agreed, but dealing with uncertainty in those numbers is an enormous > task if you want to do it right. "Doing it right", IMV, would start > out by extending all the selectivity estimation functions to include > error bars; then we could have error bars on rowcount estimates and > then costs; then we could start adding policies about avoiding plans > with too large a possible upper-bound cost. Trying to add such > policy with no data to go on is not going to work well.=0A=0AError bars w= ould be fantastic, no question. But that would make things very complex.=0A= A lot of judgment calls would be necessary for the policy behind upper-boun= d pruning, picking up on Peter's comment about "conviction multiplier of co= nviction multiplier" ;)=0AAlso, the math in deriving those bounds based on = the stats and how they propagate up the join tree doesn't seem trivial eith= er.=0A > I think Peter's point is that a quick-n-dirty patch is likely to make > as many cases worse as it makes better. That's certainly my opinion > about the topic.=0A=0AAs in my reply to Peter, I think the join level/dep= th metric is a simple but principled way of dealing with it, given the refe= renced research.=0AIn the first step, we'd use this merely to be more risk-= averse towards nested loop joins as we climb up the join tree - we are not = fiddling with the cost model itself, nor the join ordering, just when it co= mes to considering that particular join algorithm. Later this could be expa= nded to be more broadly scoped.=0A=0APlease not give up on a simple way to = reap most of the fruits just yet.