Cortex AISQL: A Production SQL Engine for Unstructured Data
Abstract
Integrating AI's semantic capabilities directly into SQL is a key goal, as it would enable users to write declarative queries that blend relational operations with semantic reasoning over both structured and unstructured data. However, achieving production-scale efficiency for semantic operations presents significant hurdles. Semantic operations inherently cost more than traditional SQL operations and possess different latency and throughput characteristics, making their application at large scales prohibitively expensive. Current query execution engines are not designed to optimize semantic operations, often leading to suboptimal query plans. The challenge is compounded because the cost and selectivity of semantic operations are typically unknown at compilation time. Snowflake's Cortex AISQL is a query execution engine that addresses these challenges through three novel techniques informed by production deployment data from Snowflake customers. First, AI-aware query optimization treats AI inference cost as a first-class optimization objective, reasoning about large language model (LLM) cost directly during query planning to achieve 2--8× speedups. Second, adaptive model cascades reduce inference costs by routing most rows through a fast proxy model while escalating uncertain cases to a powerful oracle model, with 2--6× speedups at 90--95% of oracle model quality. Third, semantic join query rewriting lowers the quadratic time complexity of join operations to linear through reformulation as multi-label classification tasks, for 15--70× speedups, often with improved prediction quality. AISQL is deployed in production at Snowflake, where it powers diverse customer workloads across analytics, search, and content understanding.
Fields of Study & Subjects
Advanced Database Systems and Queries
Semantic Web and Ontologies
Data Quality and Management
Publication details
- Journal / source
- Companion of the International Conference on Management of Data
- Publisher
- ACM
- Pages
- 400–412
- Publication date
- 26 May 2026