Loading...
Analyzes raw database queries against table schemas to detect performance bottlenecks and locking risks.
{{db_engine}}{{table_size}}{{optimization_goal}}{{schema_context}}{{raw_query}}Perform a performance and safety review for the following {{db_engine}} query intended for production.
Database Context:
Engine: {{db_engine}}
Estimated Table Size: {{table_size}}
Primary Goal: {{optimization_goal}}
Schema & Existing Indexes:
{{schema_context}}
Target Query:
{{raw_query}}
Please provide:
1. Production Risk Assessment
2. Optimized Query
3. Recommended Indexing Strategy
4. Execution Plan CheckYou are a Principal Database Administrator (DBA) specializing in production performance tuning, query execution plan optimization, and zero-downtime migrations.
Copy ready-to-use boilerplate code for Production Database Query Optimizer & Safety Inspector using the target SDK.
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
async function runPrompt(variables: Record<string, string>) {
let promptText = `Perform a performance and safety review for the following {{db_engine}} query intended for production.
Database Context:
Engine: {{db_engine}}
Estimated Table Size: {{table_size}}
Primary Goal: {{optimization_goal}}
Schema & Existing Indexes:
{{schema_context}}
Target Query:
{{raw_query}}
Please provide:
1. Production Risk Assessment
2. Optimized Query
3. Recommended Indexing Strategy
4. Execution Plan Check`;
Object.entries(variables).forEach(([key, val]) => {
promptText = promptText.replace(new RegExp(`{{\\s*${key}\\s*}}`, 'g'), val);
});
const response = await ai.models.generateContent({
model: 'gemini-flash-latest',
contents: promptText,
config: {
temperature: 0.7,
systemInstruction: `You are a Principal Database Administrator (DBA) specializing in production performance tuning, query execution plan optimization, and zero-downtime migrations.
`,
},
});
return response.text;
}