Using SPL routines with PDQ queries
The database server freezes the PDQ priority that is used to optimize SQL statements within SPL routines at the time of procedure creation or the last manual recompilation with the UPDATE STATISTICS statement. You can change the client value of PDQPRIORITY.
To change the client value of PDQPRIORITY, embed the SET PDQPRIORITY statement within the body of your SPL routine.
The PDQ priority value that the database server uses to optimize or reoptimize an SQL statement is the value that was set by a SET PDQPRIORITY statement, which must have been executed within the same procedure. If no such statement has been executed, the value that was in effect when the procedure was last compiled or created is used.
The PDQ priority value currently in effect outside a procedure is ignored within a procedure when it is executing.
CREATE PROCEDURE my_proc (a INT, b INT, c INT)
Returning INT, INT, INT;
SET PDQPRIORITY 0;
...
SET PDQPRIORITY 85;
SELECT ... (big complicated SELECT statement)
SET PDQPRIORITY 0;
...
;