neondatabase / neon

Neon: Serverless Postgres. We separated storage and compute to offer autoscaling, code-like database branching, and scale to zero.
https://neon.tech
Apache License 2.0
14.6k stars 423 forks source link

pg_hint_plan needs `load` command to work #7426

Open skyzh opened 5 months ago

skyzh commented 5 months ago

Steps to reproduce

on a local Postgres setup, it seems that pg_hint_plan needs load instead of create extension to work properly.

create extension pg_hint_plan;
create table t1(id int primary key);
create table t2(id int primary key);
create table t3(id int primary key);
create table t4(id int primary key);
EXPLAIN (COSTS false) /*+Leading( (t3 t4) )*/ SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; -- does not work
load 'pg_hint_plan';
EXPLAIN (COSTS false) /*+Leading( (t3 t4) )*/ SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; -- works

However, Neon Postgres does not support the load commands.

neondb=> load 'pg_hint_plan';
ERROR:  access to library "pg_hint_plan" is not allowed

Expected result

Actual result

Environment

Logs, links

knizhnik commented 5 months ago

I get the same behaviour with Vanilla Postgres. May be something wrong with the test?

skyzh commented 5 months ago

Slack thread -> https://neondb.slack.com/archives/C04DGM6SMTM/p1713280441791079

andreasscherbaum commented 5 months ago

This is documented: https://github.com/ossc-db/pg_hint_plan/blob/master/docs/installation.md

YanicNeon commented 5 months ago

As discussed, I asked the customer who requested this extension to share further details regarding the final objective. Our customer reports facing difficulties with a specific query. I collected the output of an explain analyze of the poor performing query. Please see: https://neondb.slack.com/archives/C04DGM6SMTM/p1715334366403299?thread_ts=1713280441.791079&cid=C04DGM6SMTM