Overview
The ML/GenAI tools leverage MySQL’s built-in AI capabilities:- Text Generation: Generate text using GenAI models with
ml_generate - Natural Language to SQL: Convert questions to SQL with
ask_nl_sql - Schema Discovery: Find relevant tables with
retrieve_relevant_schema_information - HeatWave ML Help: Get guidance on AutoML features with
heatwave_ask_help - Vector Embeddings: Create embeddings with
ragify_column(see Vector Stores)
Text Generation with ml_generate
Overview
Generate text responses using MySQL’s integrated GenAI models.Usage
ml_generate
Parameters:
connection_id(string, required): Database connection identifierquestion(string, required): Text generation prompt or instruction
Example Workflows
Summarizing Query Results
Content Generation
Data Analysis Insights
Best Practices
- Be Specific: Provide clear, detailed prompts
- Context Matters: Include relevant data or query results in your prompt
- Iterate: Refine prompts based on initial results
- Length Control: Specify desired output length if needed
The
ml_generate tool works on both MySQL AI and MySQL HeatWave connections.Natural Language to SQL (NL2SQL)
Overview
Convert natural language questions directly into SQL queries and execute them automatically.Usage
ask_nl_sql
Parameters:
connection_id(string, required): Database connection identifierquestion(string, required): Natural language question about your data
- Generated SQL query
- Query execution results
How It Works
- Schema Analysis: Analyzes your database schema
- Query Generation: Converts natural language to SQL
- Automatic Execution: Runs the generated query
- Results Return: Provides both SQL and results
Example Questions
Analytics Questions
Operational Questions
Comparison Questions
Generated SQL Examples
Question: “What is the average delay incurred by flights?”Tips for Better Results
- Use Proper Terminology: Reference actual table/column concepts
- Be Specific: Include time ranges, filters, and limits
- Test Incrementally: Start simple, then add complexity
- Review SQL: Check the generated SQL for accuracy
Schema Discovery
Overview
Automatically identify relevant tables and schemas for a natural language question.Usage
retrieve_relevant_schema_information
Parameters:
connection_id(string, required): Database connection identifierquestion(string, required): Natural language question or topic
Example Output
Question: “Which tables contain employee information?”Use Cases
Database Exploration
Data Modeling
Query Planning
This tool is especially useful before writing complex queries or when exploring unfamiliar databases.
HeatWave ML Help (NL2ML)
Overview
Ask natural language questions about MySQL HeatWave AutoML features and get guidance on using machine learning capabilities.Usage
heatwave_ask_help
Parameters:
connection_id(string, required): HeatWave database connectionquestion(string, required): Question about HeatWave ML
Example Questions
Getting Started
Model Training
Predictions
Model Management
Feature Compatibility
| Feature | MySQL AI | HeatWave | Notes |
|---|---|---|---|
| ml_generate | ✅ | ✅ | Text generation |
| ask_nl_sql | ✅ | ✅ | Natural language to SQL |
| retrieve_relevant_schema_information | ✅ | ✅ | Schema discovery |
| heatwave_ask_help | ❌ | ✅ | HeatWave-specific |
| ragify_column | ✅ | ✅ | Create embeddings |
Complete ML Workflow Example
Exploratory Analysis
Customer Intelligence
Support Ticket Analysis
Best Practices
Query Optimization
- Start Simple: Begin with basic questions, add complexity gradually
- Validate Results: Always verify generated SQL and results
- Use Filters: Include time ranges and limits to improve performance
- Index Appropriately: Ensure relevant columns are indexed
Prompt Engineering
- Be Explicit: “Show the top 5…” instead of “Show some…”
- Provide Context: Mention table names if you know them
- Specify Format: “as a percentage”, “rounded to 2 decimals”
- Include Constraints: Date ranges, status filters, etc.
Error Handling
- Review Generated SQL: Check for logical errors
- Iterate Prompts: Rephrase if results are unexpected
- Check Schema: Ensure referenced tables/columns exist
- Monitor Performance: Watch for slow queries on large datasets
Common Questions
How accurate is NL2SQL for complex queries?
How accurate is NL2SQL for complex queries?
NL2SQL works best for straightforward analytical queries (aggregations, filters, joins). Complex queries with multiple subqueries or window functions may require manual refinement. Always review the generated SQL.
Can I use ml_generate to summarize large result sets?
Can I use ml_generate to summarize large result sets?
Yes. Execute your query first with
execute_sql_tool_by_connection_id, then use ml_generate to summarize the results. Be mindful of context limits for very large result sets.Does ask_nl_sql learn from my corrections?
Does ask_nl_sql learn from my corrections?
No. Each query is independent. However, you can improve results by being more specific in your questions and using consistent terminology that matches your schema.
Can I train custom ML models?
Can I train custom ML models?
For MySQL HeatWave, use
heatwave_ask_help to learn about AutoML features. For custom models, you’ll need to use HeatWave’s ML_TRAIN and related functions directly via SQL. The MySQL MCP Server doesn’t wrap custom model training.What's the difference between ask_nl_sql and retrieve_relevant_schema_information?
What's the difference between ask_nl_sql and retrieve_relevant_schema_information?
retrieve_relevant_schema_information only returns table schemas (DDL) without executing queries. ask_nl_sql generates and executes a query to answer your question with actual data.Why isn't heatwave_ask_help working?
Why isn't heatwave_ask_help working?
This tool only works with MySQL HeatWave connections (not MySQL AI). Verify your connection mode with
list_all_connections. If you’re connected to MySQL AI, this feature isn’t available.Next Steps
Vector Stores
Learn about RAG and semantic search
API Tools
Complete tool reference
