Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aljfL-0004f0-HS for pgsql-hackers@arkaria.postgresql.org; Thu, 31 Mar 2016 20:58:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aljfK-0007E0-Kl for pgsql-hackers@arkaria.postgresql.org; Thu, 31 Mar 2016 20:58:06 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aljfJ-0007Ds-ON for pgsql-hackers@postgresql.org; Thu, 31 Mar 2016 20:58:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aljfH-00064e-8n for pgsql-hackers@postgresql.org; Thu, 31 Mar 2016 20:58:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u2VKvwHo007834; Thu, 31 Mar 2016 16:57:58 -0400 From: Tom Lane To: Dean Rasheed cc: Alvaro Herrera , Tomas Vondra , Alexander Korotkov , Mark Dilger , PostgreSQL-development Subject: Re: improving GROUP BY estimation In-reply-to: References: <20160331203407.GA162729@alvherre.pgsql> <7329.1459456853@sss.pgh.pa.us> Comments: In-reply-to Dean Rasheed message dated "Thu, 31 Mar 2016 21:46:13 +0100" Date: Thu, 31 Mar 2016 16:57:58 -0400 Message-ID: <7833.1459457878@sss.pgh.pa.us> X-Pg-Spam-Score: -2.9 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Dean Rasheed writes: > On 31 March 2016 at 21:40, Tom Lane wrote: >> Let's use something like this: >> See "Approximating block accesses in database organizations", S. B. Yao, >> Communications of the ACM, Volume 20 Issue 4, April 1977 Pages 260-261 Actually, having now looked at both the Dellera paper and the Yao one, what the latter shows seems to be equivalent to Dellera's equation (2) (the first one in his section 2.2). But what the code is actually using is the approximation in the second equation in 2.2, and that one is certainly not in Yao, although it's not hard to see how you get from the first to the second if you assume i << Nr. I think it'd be worth writing out equation (2), attributing it to the Yao paper, and then saying something like "Alberto Dellera points out that if Nd is large, so that all the values of i are much less than Nr, then this formula can be approximated by [the formula used in the code]. It turns out that that formula also works well even when Nd is small." regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers