Alan
Alan

Reputation: 3

Something about the optimizer

  1. I create a database and connect with it. But when I execute
select optimizer;

it returns

SELECT: identifier 'optimizer' unknown

What's the problem with it? And I can't find the sys table in the database using \d.

  1. If I want to add an optimizer myopt, is it enough for the steps below:
    1. write the opt_myopt.h and opt_myopt.c in /monetdb5/optimizer/
    2. Add the code into codes in /monetdb5/optimizer/opt_wrapper.c
    3. Add the function into optimizer_init_funcs in /monetdb5/optimizer/optimizer.c
    4. Add a new pipe in /monetdb5/optimizer/opt_pipes.c

Upvotes: 0

Views: 107

Answers (3)

Yunus King
Yunus King

Reputation: 1271

Concerning your second question,

You also have to create and add an optimizer pipeline to opt_pipes.c. Look for the default_pipe and then copy/paste that one to a new pipeline and add your optimizer to it.

There are some more places where you might need to add your optimizer, like in the codes[]array in opt_wrapper.c. Just mimick one of the standard optimizers like "reorder".

Upvotes: 0

Jennie
Jennie

Reputation: 405

For your first question: if your current_schema is not sys, you need to use select sys.optimizer;.

For your second question: the best existing example is probably in monetdb5/extras/mal_optimizer_template. Next to that, it's basically checking the source code to see how other optimisers have been implemented. NB, although it doesn't often happen, the internals of MonetDB can change between (major) versions. I'd recomment you to use Oct2020 or newer.

Upvotes: 0

PedroTadim
PedroTadim

Reputation: 71

Since Oct2020, variables now have a schema (to keep it other SQL objects). In your session, 'sys' is not the session's schema, that's why it cannot find the 'optimizer' variable, the same for the tables.

In default branch (will be available in the next release) I added a "schema path" property on the user to search SQL objects besides the current session's schema. By default it includes the 'sys' schema.

Upvotes: 1

Related Questions