Additional Statistics Hooks

From: Mat Arye <mat(at)timescale(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Additional Statistics Hooks
Date: 2018-03-12 17:03:57
Message-ID: CADsUR0D5yq0LJfg5jyWEAq5SE+1E-3rqF09fk7z6ykx+EM4iUw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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
the get_relation_stats_hook work well fo that since by the time it's called
you only see the `time` var and not the full expression. None of the other
hooks seem appropriate either. So 2 questions:

1) Would people be opposed to adding a code hook somewhere at the start of
`examine_variable` (selfuncs.c) to allow creating statistics on complete
expressions? I can submit a patch if this seems reasonable.

2) Do patches that add code hooks (and are probably under 10 lines) need to
go through the entire commitfest process. I guess what I am really asking
is if PG12 would be the first version such a patch could appear in or is
PG11 still a possibility? Just wondering what the policy on such stuff is.

Thanks,
Mat
TimescaleDB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-03-12 17:05:01 Re: JIT compiling with LLVM v11
Previous Message Tom Lane 2018-03-12 16:52:00 Re: Ambigous Plan - Larger Table on Hash Side