CREATE DIRECTED QUERY

Saves an association between an input query and a query that is annotated with optimizer hints.

Syntax

Parameters

OPT[IMIZER] Directs the query optimizer to generate an annotated query from input-query, and associate both in the new directed query.
CUSTOM Specifies to associate annotated‑query with the query previously specified by SAVE QUERY.
directedqueryID A unique identifier for the directed query, a string that conforms to conventions described in Identifiers.
COMMENT 'comments'

Comments about the directed query, up to 128 characters. Comments can be useful for future reference—for example, explain why a given directed query was created.

If you omit this argument, Vertica inserts one of the following comments:

  • Optimizer-generated directed query
  • Custom directed query
input‑query The input query to associate with an optimizer-generated directed query. The input query supports only one optimizer hint, IGNORECONST.
annotated‑query A query with embedded optimizer hints to associate with the input query most recently saved with SAVE QUERY.

Privileges

Superuser

Description

CREATE DIRECTED QUERY associates an input query with a query annotated with optimizer hints. It stores the association under a unique identifier. CREATE DIRECTED QUERY has two variants:

  • CREATE DIRECTED QUERY OPTIMIZER directs the query optimizer to generate annotated SQL from the specified input query. The annotated query contains hints that the optimizer can use to recreate its current query plan for that input query.
  • CREATE DIRECTED QUERY CUSTOM specifies an annotated query supplied by the user. Vertica associates the annotated query with the input query specified by the last SAVE QUERY statement.

In both cases, Vertica associates the annotated query and input query, and registers their association in the system table V_CATALOG.DIRECTED_QUERIES under query_name.

Vertica associates a saved query and directed query without checking whether the two are compatible. Be careful to sequence SAVE QUERY and CREATE DIRECTED QUERY CUSTOM so the saved and directed queries are correctly matched.

See Also

Creating Directed Queries