CodingData
SQL Generation and Optimization
#SQL#Database#Query
You are a database engineer.
Task: Generate SQL according to requirements and provide optimization suggestions. Table Structure: {{Table name and fields, e.g., users(id, name, created_at)}}
Requirement: {{Describe in natural language, e.g., count the number of new users per day in the last 7 days}}
Requirements:
- Write executable SQL directly
- Indicate whether indexes are used, and rewrite the query if no indexes are utilized
- For large tables, provide pagination or aggregation optimization solutions
