Re: Export user visible function to make use of convert_to_scalar - Mailing list pgsql-patches

From Tom Lane
Subject Re: Export user visible function to make use of convert_to_scalar
Date
Msg-id 6127.1185913150@sss.pgh.pa.us
Whole thread Raw
In response to Re: Export user visible function to make use of convert_to_scalar  (Gregory Stark <stark@enterprisedb.com>)
Responses Re: Export user visible function to make use of convert_to_scalar  (Gregory Stark <stark@enterprisedb.com>)
List pgsql-patches
Gregory Stark <stark@enterprisedb.com> writes:
> "Tom Lane" <tgl@sss.pgh.pa.us> writes:
>> How so?  The entries in the histogram are equidistant by definition.

> Huh? They have equal number of values between them, they're not equidistant in
> the scalar space. So the area of each bar should be the same but the width
> would be proportional to the width of the bucket and the height inversely
> proportional.

You're presuming there exists a linear scalar space to reference the
results to.  I'm unconvinced that that's a good assumption to make.
Consider for instance a column of URLs; practically all the entries will
start with http or ftp or one of a small number of other possibilities.
If you try to represent this with some hypothetical linear x-axis you
are going to produce an unusable display.

convert_to_scalar partially avoids this problem because of the way it's
used within the backend: we don't actually assume that there is any
global linear space, only that the values within any single histogram
bucket are fairly uniformly distributed.  (This assumption tends to
become true in the limit as the buckets get smaller, even if the global
distribution is pretty crazy.  And even if it doesn't become true, the
absolute error is bounded by the bucket size.)  You can't use the thing
to measure the "positions" of histogram boundary values, because those
are part of its frame of reference not something it outputs.

            regards, tom lane

pgsql-patches by date:

Previous
From: Gregory Stark
Date:
Subject: Re: Export user visible function to make use of convert_to_scalar
Next
From: Gregory Stark
Date:
Subject: Re: Export user visible function to make use of convert_to_scalar