Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Auto Routing

The AUTO_ROUTING Pre-hook optimizes query performance and cost efficiency by dynamically routing queries to the most suitable warehouse. This hook analyzes historical query data, execution times, and associated costs to make informed decisions.

Key features of the AUTO_ROUTING Pre-hook:

  1. Query Analysis: The hook examines incoming queries and compares them against the historical query performance data.

  2. Optimal Warehouse Selection: Based on the analysis, queries are directed to an appropriate warehouse size within the user-specified warehouse pool.

  3. Performance and Cost Optimization: The hook aims to enhance query performance while minimizing costs.

  4. Adaptive Learning: Recommendations are based on query hashes that are seen by this hook at least once within the defined look-back window, as well as additional queries identified by the training label during this period.

  5. Default Routing: For new queries without historical data, the system routes them to the default warehouse in the pool.

Sundeck intercepts each incoming query before execution. The hook checks for an existing warehouse recommendation for the query. If a recommendation exists, Sundeck routes the query to the suggested warehouse. Otherwise, it directs the query to the default warehouse in the pool.

Configuration Syntax

  'warehousePoolName' : <warehouse-pool-name>,
  'refreshFrequency'  : <refresh-frequency>,
  'lookbackPeriod'  : <lookback-period>,
  'labelName'  : <training-label-name>,
  'hint'  : <hint>,


The hook will direct queries to an appropriate warehouse size in this warehouse pool.
How often the hook should relearn/update it’s routing table. Valid values are 1 hour, 3 hours, 6 hours, 12 hours, 1 day, 2 days and 7 days. Default is 1 day.
The amount of data to review when making routing recommendations 7 days, 1 month, 3 months, 6 months and All time. Default is 1 month.
Select a label that identifies queries likely to be used with this hook. This is helpful when trying to accelerate routing decisions for infrequent queries. This is an optional parameter.
For use by sundeck support only


CREATE OR REPLACE SUNDECK FLOW "Route queries automatically based on query history"
  PRE HOOK route_tpc_queries_hook
  AUTO_ROUTING {'labelName': 'TPCDI', 'lookbackPeriod': '1 month', 'refreshFrequency': '1 hour', 'warehousePoolName': 'CS_POOL1'}

When you connect to this flow, the queries will be routed to the optimal warehouse in the warehouse pool CS_POOL1 based on the query history of the last month. The hook will refresh the routing table every hour.

See also: