Re: Proposed refactoring of planner header files

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Proposed refactoring of planner header files
Date: 2019-01-31 20:10:17
Message-ID: CA+TgmoaZNN5Xb9SfiQEeFdL+zPdqmEMym8TX7Cecfae46ZSf+Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jan 31, 2019 at 2:46 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I'm happy to do the work if there's consensus on what to do. After
> a few moments' thought, I'd suggest:
>
> 1. Move the indexscan cost estimation functions into a new file
> adt/index_selfuncs.c. Most of them already are declared in
> utils/index_selfuncs.h, and we'd move the remaining declarations
> (primarily, genericcostestimate()) to that file as well. This
> would affect #includes in contrib/bloom/ and any 3rd-party index
> AMs that might be using genericcostestimate().
>
> 2a. Leave the support functions in selfuncs.c with declarations in
> utils/selfuncs.h, and move the operator-specific estimators to
> a new file, perhaps opr_selfuncs.c. This would minimize pain for
> existing includers of selfuncs.h, most of which (particularly outside
> core) are presumably interested in the support functions.
>
> 2b. Alternatively, leave the operator-specific estimators where they
> are, and make new files under optimizer/ for the support functions.

I do not have a powerful opinion on exactly what to do here, but I
offer the following for what it's worth:

- I do not really think much of the selfuncs.c naming. Nobody who is
not deeply immersed in the PostgreSQL code knows what a "selfunc" is.
Therefore, breaking selfuncs.c into opr_selfuncs.c and
index_selfuncs.c doesn't strike me as the ideal naming choice. I
would suggest looking for a name that is less steeped in venerable
tradition; perhaps estimator.c or indexsupport.c or selectivity.c or
whatever could be considered for whatever new files we are creating.

- I have always found the placement of selfuncs.c a bit strange: why
is it in utils/adt? Perhaps there is an argument for having the
things that are specific to a particular type or a particular operator
in that directory, but if so, shouldn't they be grouped with the type
or operator to which they relate, rather than each other? And if
they're not specific to a certain thing, or if grouping them with that
thing would suck because of what we'd have to #include or some other
grounds, then why not put them in the optimizer? I think that a large
fraction of this code is actually generic, and putting it in the
optimizer directory someplace would be more logical than what we have
now. Alternatively, since these have to be exposed via pg_proc, maybe
the shims should go in this directory and the core logic elsewhere.
Again, I don't have a strong opinion here, but I've never thought this
made a ton of sense the way it is.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jesper Pedersen 2019-01-31 20:28:43 Re: pg_upgrade: Pass -j down to vacuumdb
Previous Message Tom Lane 2019-01-31 20:04:04 Re: pgsql: Build src/port files as a library with -fPIC, and use that in li