Hola a tod@s.
Tengo una pequeña duda con respecto a la eficiencia de ejecución de las consultas paramétricas vs consultas estáticas.
¿A que me refiero?
Una consulta parametrica
Código Delphi
[-]
Consulta.SQL.Add('SELECT A, B, C');
Consulta.SQL.Add('FROM TABLA')
Consulta.SQL.Add('WHERE A = :VALOR1')
Consulta.SQL.Add(' AND B = :VALOR2')
Consulta.Params.ParamByName('VALOR1').Value := Var1;
Consulta.Params.ParamByName('VALOR2').Value := Var2;
es más eficiente a una consulta estática
Código Delphi
[-]
Consulta.SQL.Add('SELECT A, B, C');
Consulta.SQL.Add('FROM TABLA')
Consulta.SQL.Add('WHERE A = '+QuotedStr(Var1))
Consulta.SQL.Add(' AND B = '+IntToStr(Var2))
Si!. el código es mas legible y se puede administrar mejor, pero me refiero a si no solo es una buena práctica sino que también influye en el desempeño de la aplicación.
Cita:
Parameterized statements are cached to facilitate reuse and avoid compilation overhead, which is especially important in high-volume OLTP environments. Furthermore, using stored procedures further promotes caching and reuse.
The only downside to parameters from a performance perspective is that a given plan may be optimal for some values but not others. In cases where sub-optimal cached plans are an issue, techniques such as RECOMPILE hints or compromise plan guides can help avoid a sub-optimal execution plans due to varying parameter values. See article Batch Compilation, Recompilation, and Plan Caching Issues in SQL Server 2005 for more information.
|
link:
http://weblogs.sqlteam.com/dang/arch...-Practice.aspx
He encontrado lo anterior en una entrada de blog pero quisiera saber sus puntos de vista
De antemano, gracias por sus aportes.