Plan Guides - Buena característica de SQL Server 2005

En este post anterior, contaba un problema que se nos estaba dando en una instalación con una consulta muy sencilla, por clave primaria en una tabla unos 300.000 únicamente y que ejecutaba en forma muy pobre. El problema se daba cuando se ejecutaba en servidores con 4 procesadores y Microsoft SQL Server 2000, con SP4.

Buscando soluciones, encontré que para SQL Server 2005, existen los "Plan Guides", que es una forma de agregar hints o forzar planes de ejecución en sentencias SQL sin tener que modificar la misma. Si bien deberían ser usados con precaución, son una bendición para cuando estamos optimizando programas de los cuales no disponemos los fuentes, o aplicaciones GeneXus (u otros generadores de código), donde no se pueden agregar hints en forma fácil.

Si hubiésemos estado en SQL Server 2005, podríamos haber forzado la ejecución por indice de la clave primaria, sin tener que hacer otras modificaciones.

Hay mas información en Understanding Plan Guides:

"SQL Server 2005 introduces the sp_create_plan_guide system stored procedure for creating plan guides to optimize the performance of queries. This procedure can be used when you cannot or do not want to change the text of the query directly. Plan guides can be useful when a small subset of queries in a database application deployed from a third-party vendor are not performing as expected. Plan guides influence optimization of queries by attaching query hints to them. In the sp_create_plan_guide statement, you specify the query that you want optimized and the OPTION clause that contains the query hints you want to use to optimize the query. When the query executes, SQL Server matches the query to the plan guide and attaches the OPTION clause to the query at run time.
Note:
Plan guides can be created and used only in the SQL Server 2005 Standard and Enterprise editions. Plan guides can be dropped in all editions."

Ver también:
Optimizing Queries in Deployed Applications by Using Plan Guides
Using SQL Server Profiler to Create and Test Plan Guides
sp_create_plan_guide
sp_control_plan_guide

Comentarios

Entradas más populares de este blog

La nefasta influencia del golero de Cacho Bochinche en el fútbol uruguayo

Aplicación monolítica o distribuida?

Funcionalidades de GeneXus que vale la pena conocer: DATE Constants.