Re: [HACKERS] get_relation_stats_hook() - Mailing list pgsql-patches

From Tom Lane
Subject Re: [HACKERS] get_relation_stats_hook()
Date
Msg-id 12400.1215716369@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] get_relation_stats_hook()  (Simon Riggs <simon@2ndquadrant.com>)
Responses Re: [HACKERS] get_relation_stats_hook()
Re: [HACKERS] get_relation_stats_hook()
List pgsql-patches
Simon Riggs <simon@2ndquadrant.com> writes:
> On Thu, 2008-06-26 at 12:50 -0400, Tom Lane wrote:
>> I think you need to move up a level, and perhaps refactor some of the
>> existing code to make it easier to inject made-up stats.

> I've looked at ways of refactoring this, but the hooks provided here
> complement the existing functionality fairly well.

The hooks proposed here are completely useless --- it's impossible
to return anything except actual catalog data, because whatever is
returned is going to be subjected to ReleaseSysCache() later on.
I'd think you at least need to be able to turn that into a no-op,
or perhaps a pfree() call.  Also it's clear that some calls of
examine_variable would still return regular syscache entries, so
the cleanup behavior has to be determinable on a per-call basis.

I also still think that you need to reconsider the level at which
the hook gets control.  It's impossible given these hook definitions
to create "fake" data for an appendrel or sub-SELECT, which seems to
me to be an important requirement, at least till such time as the
core planner handles those cases better.

My feeling is that the hooks ought to be at more or less the same
semantic level as examine_variable and ReleaseVariableStats, and that
rather than making special-case hooks for the other couple of direct
accesses to STATRELATT, the right thing is to make sure that the
examine_variable hook will work for them too.

I do now concur that having the hook return a pg_statistic tuple
is appropriate --- after looking at the code that uses this stuff,
decoupling that representation would be more work than it's worth.

I think it might be a good idea to prepare an actual working example
of a plug-in that does something with the hook in order to verify
that you've got a useful definition.

            regards, tom lane

pgsql-patches by date:

Previous
From: "Pavel Stehule"
Date:
Subject: Re: review: table function support
Next
From: Simon Riggs
Date:
Subject: Re: [HACKERS] get_relation_stats_hook()