skip to Main Content

Can I add a hint clause to a materialized view in PostgreSQL as follows? or is there another way?

ex1.

CREATE MATERIALIZED VIEW MV1
/*+
IndexScan(tableA)
*/
SELECT...

ex2.

/*+
IndexScan(tableA)
*/
REFRESH MATERIALIZED VIEW MV1

I tried both, but ex1 didn’t work.

If possible, I’d like to do it ex1 way (include hint_plan in CREATE MATERIALIZED VIEW query).

Thanks for your help.

2

Answers


  1. Hint clauses are not directly supported by PostgreSQL in CREATE MATERIALIZED VIEW. Usually, hints are included in the question, like:

    SELECT /*+ IndexScan(tableA) */ columns FROM MV1;
    
    Login or Signup to reply.
  2. Experimentally, the hint works when the query is run upon initial construction, but then is ignored upon refresh. Maybe this would best be addressed to pg_hint_plan’s issue tracker.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search