Append a hint to SQL query

17 views
Skip to first unread message

Q&A Bot

unread,
Jan 14, 2022, 3:41:42 AM1/14/22
to seektab...@googlegroups.com

Q: In order to force parallel plan execution with SQL Server queries we need to add  hints at the end of grouping query composed by SeekTable. 
If a hint is included into "Select Query" it doesn't work because SeekTable may wrap it with outer SELECT. How to add a hint to guarantee that it will be at the end of the whole SQL query?

It is possible to add a hint by specifying it in the "Conditional JOINs" section:
image.png
Notes:
  • If "Apply for Dimensions" are not specified then this SQL will be appended in all cases
  • Hints should be last entries in the "Conditional JOINs" list
Sometimes a hint should be included only if a certain dimension (or measure) is used in the report. 
It's easy to have a conditional hint in this way:
  • configure a report parameter that will calculate a condition for the hint:
    image.png
    Expression should be like that: Measures.Contains("FIRST_VALUE_MSR_NAME") ? 1 : null
  • Apply hint SQL conditionally:
    @applyHint[ OPTION(USE HINT('ENABLE_PARALLEL_PLAN_PREFERENCE')) ]
Reply all
Reply to author
Forward
0 new messages