Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aljgy-0004i2-UO for pgsql-hackers@arkaria.postgresql.org; Thu, 31 Mar 2016 20:59:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aljgy-0000JX-HK for pgsql-hackers@arkaria.postgresql.org; Thu, 31 Mar 2016 20:59:48 +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 1aljgx-0000JG-Kz for pgsql-hackers@postgresql.org; Thu, 31 Mar 2016 20:59:47 +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 1aljgv-00065B-7I for pgsql-hackers@postgresql.org; Thu, 31 Mar 2016 20:59:46 +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 u2VKxfWa007901; Thu, 31 Mar 2016 16:59:41 -0400 From: Tom Lane To: Dean Rasheed cc: Tomas Vondra , Alexander Korotkov , Mark Dilger , PostgreSQL-development Subject: Re: improving GROUP BY estimation In-reply-to: References: <56CD0381.5060502@2ndquadrant.com> <03A3B58D-6A2D-44FE-9B03-E21948CFCBAA@gmail.com> <56CFA373.3060105@2ndquadrant.com> <7D1A65E8-7ED8-4268-9C24-8EA07E95D2BC@gmail.com> <56CFCE96.5080306@2ndquadrant.com> <56D867C3.3040309@2ndquadrant.com> <904EB795-BCDD-4D68-8D44-274B40C4B2E9@gmail.com> <56D88D93.5000509@2ndquadrant.com> <1457097036.24980.28.camel@2ndquadrant.com> <1457906984.27231.16.camel@2ndquadrant.com> <715c5c66-5fe1-a9aa-e28d-6c4114ba0fd6@2ndquadrant.com> <20518.1459451903@sss.pgh.pa.us> Comments: In-reply-to Dean Rasheed message dated "Thu, 31 Mar 2016 21:43:58 +0100" Date: Thu, 31 Mar 2016 16:59:41 -0400 Message-ID: <7900.1459457981@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: > Yeah, that makes sense. In fact, if we only apply the adjustment when > reldistinct > 0 and rel->rows < rel->tuples, and rewrite the first > argument to pow() as (rel->tuples - rel->rows) / rel->tuples, then it > is guaranteed to be non-negative. If rel->rows >= rel->tuples (not > sure if it can be greater), then we just want the original > reldistinct. Works for me. 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