CREATE QUERY POLICY
View as Markdown
PREVIEW
This feature is in
private preview.
It is under active development and may have stability or performance issues.
It isn't subject to our backwards compatibility guarantees.
To enable this feature for your environment, contact our team.
To enable this feature for your environment, contact our team.
CREATE QUERY POLICY creates a query policy. A
query policy contains rules that warn about or reject queries based on their
execution plan. A policy has no effect until you attach it to a cluster with
ALTER CLUSTER or CREATE CLUSTER.
Syntax
CREATE QUERY POLICY <name> (
[MODE = '<mode>',]
RULES (
<rule_name> (action = 'reject', metric = 'query_plan_includes', value = '<plan_feature>')
[, ...]
)
)
;
| Syntax element | Description | ||||||
|---|---|---|---|---|---|---|---|
<name>
|
The name of the query policy. | ||||||
MODE
|
Optional. What happens when a query matches a rule.
Default: |
||||||
RULES
|
The rules in the policy. Specify RULES () to create a policy with no
rules.
|
||||||
<rule_name>
|
The name for the rule. Must be unique within the query policy. | ||||||
<plan_feature>
|
The execution plan feature the rule rejects.
See Choosing a rule. |
Details
Query policies are plan-based admission controls, not resource limits. Materialize checks the optimized execution plan of a query before it runs. A fast path read from an existing index matches neither rule, even if it returns many rows.
For which statements a policy checks, see Query policies.
Privileges
The privileges required to execute this statement are:
CREATEQUERYPOLICYprivileges on the system.
Examples
CREATE QUERY POLICY indexed_reads_only (
MODE = 'enforce',
RULES (
no_temporary_dataflows (action = 'reject', metric = 'query_plan_includes', value = 'temporary_dataflow')
)
);
ALTER CLUSTER serving SET (QUERY POLICY = indexed_reads_only);