Skip to content

DT-118: Implement "Fix with AI" for SQL query optimization#119

Merged
kigiri merged 2 commits intomasterfrom
118-implement-fix-with-ai-for-sql-query-optimization
Apr 15, 2026
Merged

DT-118: Implement "Fix with AI" for SQL query optimization#119
kigiri merged 2 commits intomasterfrom
118-implement-fix-with-ai-for-sql-query-optimization

Conversation

@abdotop
Copy link
Copy Markdown
Member

@abdotop abdotop commented Apr 14, 2026

Implement AI-based SQL query optimization analysis feature

@abdotop abdotop requested a review from kigiri April 14, 2026 11:05
@abdotop abdotop self-assigned this Apr 14, 2026
@abdotop abdotop linked an issue Apr 14, 2026 that may be closed by this pull request
@abdotop abdotop changed the title DT-118: Implement "Fix with AI" for SQL query optimization #118 DT-118: Implement "Fix with AI" for SQL query optimization Apr 14, 2026
api/fix-query.ts Outdated

export async function analyzeQueryWithAI(metric: unknown, schema: unknown) {
const payload = JSON.stringify({ schema, metrics: [metric] }, null, 2)
const prompt = promptTemplate.replace('{{QUERY_METRICS_JSON}}', payload)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename QUERY_METRICS_JSON by QUERY_DETAILS_JSON

await withDeploymentTableAccess(ctx, deployment)
const schema = DatabaseSchemasCollection.get(deployment)
try {
const analysis = await analyzeQueryWithAI(metric, schema)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would convert markdown to HTML here in the backend instead of doing it in the front end

const data = fixQueryApi.data
if (!data) return
untracked(() => {
if (!analysisCache.value.has(data.id)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use .peek() instead of untracked

if (!data) return
const cashe = analysisCache.peek()

if (!cashe.has(data.id)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

@kigiri kigiri merged commit 1eac765 into master Apr 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement "Fix with AI" for SQL query optimization

2 participants