pg_hint_plan icon indicating copy to clipboard operation
pg_hint_plan copied to clipboard

Tolerating preceding single-line comments

Open LukeNotable opened this issue 1 year ago • 2 comments

(Raising this here from my StackOverflow.)

Basically, I would like to allow us to use pg_hint_plan through Metabase, and the obstacle is that this tool prepends a single-line comment, so that the database sees a query like this, for example:

-- Metabase:: userID: 123 queryType: native queryHash: 4567890
explain analyze
/*+ SeqScan(users) */
select id from users where email = 'test@me'

The docs say:

pg_hint_plan reads hints from only the first block comment

That sounds like the single-line comment ought to be simply ignored, but when I try it, it seems to prevent pg_hint_plan from doing anything. (Same under Postgres 15 and 16.)

Is there any workaround? And if not, assuming there's no intention to support hinting in such single-line comments, can they just be ignored?

LukeNotable avatar Feb 11 '24 23:02 LukeNotable