Azure / Azure/data-api-builder

Evaluate potential redundancies in our generated SQL query

Aperta
#2,413 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
improvement triage
Lingua principale
C#
Stelle
1.5k
Fork
370
Merge medio
3g 22h
PR unite (30g)
9

Descrizione

This issue is related to #2412. And aims at bringing further optimization.

The current generated SQL query for UPDATE/DELETE includes a second SELECT @ROWS_TO_UPDATE operation. We need to evaluate if this second SELECT is necessary or if it can be removed to further optimize the script.

## Current Generated Query
```
DECLARE @ROWS_TO_UPDATE int;

SET @ROWS_TO_UPDATE = (SELECT COUNT(*) as cnt_rows_to_update FROM [dbo].[todo] WHERE [dbo].[todo].[id] = @param0);

SELECT @ROWS_TO_UPDATE as cnt_rows_to_update;

IF @ROWS_TO_UPDATE = 1
BEGIN
UPDATE [dbo].[todo]
SET [dbo].[todo].[position] = @param1, [dbo].[todo].[owner_id] = @param2
OUTPUT Inserted.[id] AS [id], Inserted.[title] AS [title], Inserted.[completed] AS [completed], Inserted.[owner_id] AS [owner_id], Inserted.[position] AS [order]
WHERE [dbo].[todo].[id] = @param0;
END
```

## Objective
Determine if the second SELECT @ROWS_TO_UPDATE is necessary for the functionality. If it is not required, remove it to streamline the script.

## Tasks

1. Review the current generated query to understand the purpose of the second SELECT @ROWS_TO_UPDATE.
2. Identify all instances and test the query without the second SELECT @ROWS_TO_UPDATE to ensure it still functions correctly.
3. If the second select is not required, refactor the query to remove it.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Non sono indicati file o test. Inizia individuando il generatore delle query UPDATE/DELETE e analizza la issue #2412 correlata; identifica ogni utilizzo del secondo SELECT, quindi esegui i test delle query pertinenti o le verifiche sul database. Il lavoro è completato quando il SELECT viene rimosso solo se la funzionalità e i risultati restituiti rimangono corretti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp, sql
Ambito
backend, databases
Tipo di issue
Refactoring
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.