ossc-db / pg_hint_plan

Extension adding support for optimizer hints in PostgreSQL
Other
696 stars 103 forks source link

Why don't set GUC variables manually? #137

Closed danolivo closed 1 year ago

danolivo commented 1 year ago

Hi, As I see in readme, this extension gives a possibility to set some very restricted set of GUC's with hints. But we have SetConfigOption() in the core, which allows to change parameter by its name. For example, for some huge queries I would like to disable nestloop and MergeJoins at all. Sometimes I need to change behaviour of an extension (pg_stat_stetements, as an example) for a query, which I know should be executed as quickly as possible. And many other applications could be shown here. Do you have some reasons in mind for not implementing such feature, or it is just didn't need?

michaelpq commented 1 year ago

Isn't what a Set hint can does, though you are mentioning it? It would enforce a GUC to use a custom value before going through the planner hook, for example, one can do something like that to control the spilling of tuples to disk:

/*+ Set(work_mem "1MB") */ SELECT generate_series(1,10000);

Or are you looking for something specific that this is not able to achieve? If possible, could you describe in a simple example what Set hints are not able to do for the case you are looking for? Set hints rely on set_config_option() for their internals, FWIW. Controlling GUCs loaded from other extensions via shared_preload_libraries should be equally OK.