Re: Additional Statistics Hooks

2018-03-30 Thread Ashutosh Bapat
On Thu, Mar 15, 2018 at 7:59 PM, Tomas Vondra wrote: > > > On 03/15/2018 06:00 AM, Ashutosh Bapat wrote: >> On Tue, Mar 13, 2018 at 8:55 PM, Mat Arye wrote: Like cost associated with a function, we may associate mapping cardinality

Re: Additional Statistics Hooks

2018-03-15 Thread Tomas Vondra
On 03/15/2018 06:00 AM, Ashutosh Bapat wrote: > On Tue, Mar 13, 2018 at 8:55 PM, Mat Arye wrote: >>> >>> Like cost associated with a function, we may associate mapping >>> cardinality with a function. It tells how many distinct input values >>> map to 1 output value. By

Re: Additional Statistics Hooks

2018-03-14 Thread Ashutosh Bapat
On Tue, Mar 13, 2018 at 8:55 PM, Mat Arye wrote: >> >> Like cost associated with a function, we may associate mapping >> cardinality with a function. It tells how many distinct input values >> map to 1 output value. By input value, I mean input argument tuple. In >> Mat's case

Re: Additional Statistics Hooks

2018-03-13 Thread Tom Lane
Mat Arye writes: > An example, of a case a protransform type system would not be able to > optimize is mathematical operator expressions like bucketing integers by > decile --- (integer / 10) * 10. Uh, why not? An estimation function that is specific to integer divide

Re: Additional Statistics Hooks

2018-03-13 Thread Mat Arye
On Tue, Mar 13, 2018 at 6:31 AM, David Rowley wrote: > On 13 March 2018 at 11:44, Tom Lane wrote: > > While it would certainly be nice to have better behavior for that, > > "add a hook so users who can write C can fix it by hand" doesn't seem >

Re: Additional Statistics Hooks

2018-03-13 Thread Mat Arye
On Tue, Mar 13, 2018 at 6:56 AM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > On Tue, Mar 13, 2018 at 4:14 AM, Tom Lane wrote: > > Mat Arye writes: > >> So the use-case is an analytical query like > > > >> SELECT date_trunc('hour', time) AS

Re: Additional Statistics Hooks

2018-03-13 Thread Ashutosh Bapat
On Tue, Mar 13, 2018 at 4:14 AM, Tom Lane wrote: > Mat Arye writes: >> So the use-case is an analytical query like > >> SELECT date_trunc('hour', time) AS MetricMinuteTs, AVG(value) as avg >> FROM hyper >> WHERE time >= '2001-01-04T00:00:00' AND time <=

Re: Additional Statistics Hooks

2018-03-13 Thread David Rowley
On 13 March 2018 at 11:44, Tom Lane wrote: > While it would certainly be nice to have better behavior for that, > "add a hook so users who can write C can fix it by hand" doesn't seem > like a great solution. On top of the sheer difficulty of writing a > hook function, you'd

Re: Additional Statistics Hooks

2018-03-12 Thread Tom Lane
Mat Arye writes: > So the use-case is an analytical query like > SELECT date_trunc('hour', time) AS MetricMinuteTs, AVG(value) as avg > FROM hyper > WHERE time >= '2001-01-04T00:00:00' AND time <= '2001-01-05T01:00:00' > GROUP BY MetricMinuteTs > ORDER BY MetricMinuteTs DESC;

Re: Additional Statistics Hooks

2018-03-12 Thread Euler Taveira
2018-03-12 14:03 GMT-03:00 Mat Arye : > I have a question about statistics hooks. I am trying to teach the planner > that when grouping by something like date_trunc('1 day', time) will produce > a lot less rows than the number of distinct time values. I want to do that > in an

Additional Statistics Hooks

2018-03-12 Thread Mat Arye
Hi All, I have a question about statistics hooks. I am trying to teach the planner that when grouping by something like date_trunc('1 day', time) will produce a lot less rows than the number of distinct time values. I want to do that in an extension. The problem is that I don't see a way to make