pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Alexander Korotkov <a.korotkov@postgrespro.ru>
Cc: Mark Dilger <hornschnorter@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: improving GROUP BY estimation
Date: Thu, 31 Mar 2016 15:18:23 -0400
Message-ID: <20518.1459451903@sss.pgh.pa.us> (raw)
In-Reply-To: <CAEZATCWQ3L8rKsp0+GbO-7D2weYjxZU3668fJx1ZgoVa_QL1LA@mail.gmail.com>
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>
	<CAPpHfdtEiXqj52kuGMEnw6EShrzj-0tFYwwxPqzdFvxYfCr+tQ@mail.gmail.com>
	<56D867C3.3040309@2ndquadrant.com>
	<904EB795-BCDD-4D68-8D44-274B40C4B2E9@gmail.com>
	<56D88D93.5000509@2ndquadrant.com>
	<CAPpHfdvOBwfGQ_F6Nk+eKF0e2Bx4Z_esg7==8KAjKqP6+5-ahA@mail.gmail.com>
	<E00A6146-D40C-4E4E-92B2-D6F5017F9B19@gmail.com>
	<1457097036.24980.28.camel@2ndquadrant.com>
	<CAEZATCU3hhRjGbvCydP-i3ik4FGX9OcXsK2ZG5TGuVnJOvb=kg@mail.gmail.com>
	<1457906984.27231.16.camel@2ndquadrant.com>
	<715c5c66-5fe1-a9aa-e28d-6c4114ba0fd6@2ndquadrant.com>
	<CAEZATCVd9cACCX_fiFSa0sHiUR5JdzrYL_1N79-PYQe9WSaTWA@mail.gmail.com>
	<CAPpHfdvcS+NVHW9b8ijJUEt=iCN6F6sLez87QzT0svqd8GgDVg@mail.gmail.com>
	<CAPpHfdswn19iSnpsukEJiAQSxK63Ewhkae=GDLuWrgvVHRP5jw@mail.gmail.com>
	<3457190a-29df-8ecc-6208-a780b8faeb64@2ndquadrant! .com>
	<CAEZATCWQ3L8rKsp0+GbO-7D2weYjxZU3668fJx1ZgoVa_QL1LA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Dean Rasheed <dean.a.rasheed@gmail.com> writes:
> On 30 March 2016 at 14:03, Tomas Vondra <tomas.vondra@2ndquadrant.com> wrote:
>> Attached is v4 of the patch

> Thanks, I think this is good to go, except that I think we need to use
> pow() rather than powl() because AIUI powl() is new to C99, and so
> won't necessarily be available on all supported platforms. I don't
> think we need worry about loss of precision, since that would only be
> an issue if rel->rows / rel->tuples were smaller than maybe 10^-14 or
> so, and it seems unlikely we'll get anywhere near that any time soon.

I took a quick look.  I concur with using pow() not powl(); the latter
is not in SUS v2 which is our baseline portability expectation, and in
fact there is *noplace* where we expect long double to work.  Moreover,
I don't believe that any of the estimates we're working with are so
accurate that a double-width power result would be a useful improvement.

Also, I wonder if it'd be a good idea to provide a guard against division
by zero --- we know rel->tuples > 0 at this point, but I'm less sure that
reldistinct can't be zero.  In the same vein, I'm worried about the first
argument of pow() being slightly negative due to roundoff error, leading
to a NaN result.

Maybe we should also consider clamping the final reldistinct estimate to
an integer with clamp_row_est().  The existing code doesn't do that but
it seems like a good idea on general principles.

Another minor gripe is the use of a random URL as justification.  This
code will still be around when that URL exists nowhere but the Wayback
Machine.  Can't we find a more formal citation to use?

			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



view thread (34+ messages)  latest in thread

Message-ID: <20518.1459451903@sss.pgh.pa.us>
Permalink:  ../20518.1459451903@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20518.1459451903@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dean.a.rasheed@gmail.com, tomas.vondra@2ndquadrant.com, a.korotkov@postgrespro.ru, hornschnorter@gmail.com
  Subject: Re: improving GROUP BY estimation
  In-Reply-To: <20518.1459451903@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox