Azure / Azure/data-api-builder
Evaluate potential redundancies in our generated SQL query
- Lenguaje dominante
- C#
- Estrellas
- 1.5k
- Forks
- 370
- Merge medio
- 3 d 22 h
- PR fusionados (30 d)
- 9
Descripción
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.
Guía de contribución
Línea de trabajo
No se nombran archivos ni pruebas. Comienza localizando el generador de consultas UPDATE/DELETE y revisa el issue #2412 relacionado; identifica cada uso del segundo SELECT y luego ejecuta las pruebas de consultas pertinentes o las comprobaciones de la base de datos. Se considera terminado cuando el SELECT se elimina solo si la funcionalidad y los resultados devueltos siguen siendo correctos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp, sql
- Área
- backend, databases
- Tipo de issue
- Refactorización
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100