SQL Prompt Generation Using Query Logs and Data Profiling
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods for generating text-to-structured query language (SQL) queries using large language models (LLMs) face challenges in handling complex business databases with poorly documented tables and unclear data constraints, requiring costly human expertise for prompt engineering that does not scale well.
Innovation Solution
Automatically infer metadata from query logs and perform database profiling to generate prompts for LLMs, using query features and statistical analysis to improve the generation of SQL queries for complex databases.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If human expertise is used for prompt engineering to handle complex business databases, then query generation accuracy is improved, but cost and scalability deteriorate
Solution Approach 1:
The system performs self-service by automatically inferring metadata from query logs and performing database profiling without human intervention. The processing system autonomously generates prompts for language models by analyzing historical query patterns and database structures, eliminating the need for costly human prompt engineering while maintaining scalability.
Solution Approach 2:
The patent introduces an intermediary processing system that acts as a mediator between the complex business database and the language model. This intermediary automatically infers metadata, constructs prompts, and translates user intent into SQL queries, bridging the gap without requiring direct human expertise in prompt engineering.
2Measurement precision
If manual prompt engineering is used for complex databases, then query accuracy is improved, but time consumption and cost increase
Solution Approach 1:
The system performs preliminary actions by automatically inferring metadata and constructing prompts before the language model generates SQL queries. The processing system pre-processes database schemas, query logs, and data profiles to create optimized prompts, eliminating the need for time-consuming manual prompt engineering while maintaining high query accuracy.
3Ease of manufacture
If existing LLM methods are used without metadata inference, then implementation simplicity is maintained, but query generation effectiveness deteriorates for complex databases
Solution Approach 1:
The patent segments the query generation process into distinct automated components: metadata inference from query logs, database profiling, prompt construction, and language model execution. Each segment handles a specific task automatically, maintaining implementation simplicity while significantly improving query generation effectiveness for complex business databases.
Data Source
AI summary
In one example, a method performed by a processing system including at least one processor includes automatically inferring metadata about a structured query language database, constructing, based on the metadata, a prompt for generating a new structured query language query to be executed against the structured query language database, and providing the prompt to a language model for use in generating the new structured query language query.


