Closed MatteoSp closed 1 year ago
The alias "TS" in your query is not enclosed in double quotes, so it gets case folded down to "ts", just like table names do. But in the hint, case folding does not apply, so "TS" is not equal to ts. Use the lower case spelling of the hint /*+ BitmapScan(ts) */
, and it works.
thanks. and there's no way to use the table names in hints when the query uses aliases?
The handling of the object names is documented. See https://pg-hint-plan.readthedocs.io/en/latest/hint_details.html#upper-and-lower-case-handling-in-object-names.
thanks @michaelpq. I'm not sure how to interpret this:
Unlike the way PostgreSQL handles object names, pg_hint_plan compares bare object names in hints against the database internal object names in a case-sensitive manner. Therefore, an object name TBL in a hint matches only “TBL” in the database and does not match any unquoted names like TBL, tbl or Tbl.
From my understanding the "Skus" in the hint should match the table name, is that correct? Is - as suggested by @jeffjanes - putting the alias within the hint the only way to get it work given I have alias in the query?
Using 'pg_hint_plan' v 1.4 on Postgres 14.7
I was fighting to have may hint used in quite simple query:
for which the logs say:
It was very frustrating not being able to understand why my hint was not used, then - just for trying - I executed:
and my hint got used, with logs saying:
I also tried to put the alias in the hint comment: `/+ BitmapScan("TS") /', but it has no effect.
Am I missing something or doing any mistake?