Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hPSIt-0006UW-Rf for pgsql-general@arkaria.postgresql.org; Sat, 11 May 2019 13:44:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hPSHs-00077u-S1 for pgsql-general@arkaria.postgresql.org; Sat, 11 May 2019 13:43:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hPSHq-00074E-QN for pgsql-general@lists.postgresql.org; Sat, 11 May 2019 13:43:40 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hPSHi-0001uL-34 for pgsql-general@postgresql.org; Sat, 11 May 2019 13:43:38 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id CE09920E15; Sat, 11 May 2019 09:43:26 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sat, 11 May 2019 09:43:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=8 CXXofZjlw5x1BehAwiMxmICXTGYL6kavqni8ja+tpU=; b=Ji0L6NIqioAW+k5Wl 0SsyFsZfb3ncnNMIeqPSaW2g8QtAMDQDDtQDhFRh8ePHJdsGCvjG8WarS4n4KW/k j8LV7EA6Y+IN6m8Qh2akHURgAwRBOMyfm1bR53xp4dxLyE3Gx9UCc/5BQ+m1Udu4 YnE8s0P1G9007F8d8eu2Nxcwb1Zr/GTpg2puiUK7100dR4BPujldfleNUjnjlzc1 yfkVzWk08yGNJ6ZzqdFSwc9bdhgrnZn9+lgL0SwlVvDZ9Z//0XI0BsP0jK8LFxkn Xa2HQm3f3vAlMnrt/dHlnnUBnPQO/i42ZSeLr6QWYOww+H9gQ0YOZedCGi23IFIK NIK7A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=8CXXofZjlw5x1BehAwiMxmICXTGYL6kavqni8ja+t pU=; b=f03KPJbxlcuXJBItOWjJ3WxaR1HIF+4DHCVXcAjJpSFsic3Sopu6qMWkd XalCPvMka2bOxdp8b+ItNOHLApn7Y7pFl/ric6LAMxQ5uYGUPGheD6Bv+PYjy7fb sZj6CBxaNiL0SpMSvvkWkwavvn63pECXiNMVYjiuRtv9N81omVMPz3yZTkjVCe92 CVfs6tZxKkbsUK2/11tXAXUcrJ2IaDJthKp8zq1M/8RN8Fc/VX8To/UpoHewh3jK Q77v9N7hfA4CrPkl69n8a53oHPMjKj79A7EHU4Xl9VdLR10SksFpjaytigT0wLrF gIa3HVi+JXD/+R0pYI+w9JlYvNBwg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrledtgdeilecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesthejre dttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhl rghvvghrsegrkhhlrghvvghrrdgtohhmqeenucffohhmrghinhepphhoshhtghhrvghsqh hlrdhorhhgnecukfhppeejuddrvdduvddrudehtddrvddtvdenucfrrghrrghmpehmrghi lhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhenucevlh hushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.4] (unknown [71.212.150.202]) by mail.messagingengine.com (Postfix) with ESMTPA id B4B5810379; Sat, 11 May 2019 09:43:25 -0400 (EDT) Subject: Re: Question about Expected rows value in EXPLAIN output for Nested Loop node To: bb ddd Cc: pgsql-general@postgresql.org References: <1078310664.976303.1557490584037@nm63.abv.bg> <302576964.978332.1557491557322@nm63.abv.bg> <7ad0fba4-73b3-1459-93a7-a30cdcbb5bb9@aklaver.com> <2072988616.995164.1557503801848@nm63.abv.bg> <288922811.129669.1557567206864@nm62.abv.bg> From: Adrian Klaver Message-ID: Date: Sat, 11 May 2019 06:43:24 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <288922811.129669.1557567206864@nm62.abv.bg> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 5/11/19 2:33 AM, bb ddd wrote: > > Thanks, Adrian, but i was looking for something that goes into more depth. > For example there is one case described there where we have a Nested Loop with rows=33, and its 2 child nodes have each rows=10. > But first of all this is a very exotic join condition (t1.hundred < t2.hundred) and second of all i cannot find any explanation how this number 33 is derived. They literally spend less than 2 sentences on this case. > > In my case i as well have Nested Loop's rows value different than the product of its 2 children's rows values, but with a normal join condition on a foreign key. > My guesses (again) are the same way it keeps some statistics (very curious what exactly) about what is the probability 2 random rows from each table satisfy that condition https://www.postgresql.org/docs/11/planner-stats-details.html (t1.hundred < t2.hundred), it also keeps statistics what is the probability 2 random rows from each table satisfy the regular normal join condition like the one i have in my case (basically t1.t2_id=t2.id). And in both cases it just applies that probability to the product of the rows values of the 2 child nodes, to calculate the expected rows value of the result of the Nested Loop. But i am just guessing. > > > > > > -- Adrian Klaver adrian.klaver@aklaver.com