Query Processing - Forced Parameterization
From SQLServerPedia
|
QPFP Query Processing - Forced Parameterization n STOC50 See Also: Main_Page - Monitoring & Tuning - Query Processing SQL Server can auto-parameterize some queries to aid with execution plan reuse. This process is called simple parameterization. However, with simple parameterization SQL Server can only parameterize a small subset of queries. You can use the ALTER DATABASE command to set parameterization option to FORCED and thereby advise SQL Server to parameterize all SELECT, INSERT, UPDATE and DELETE statements. For example, the following statement changes parameterization option to forced in the AdventureWorksDW database: ALTER DATABASE AdventureWorksDW SET PARAMETERIZATION FORCED Alternatively you can set this option from the database properties dialog. The performance of transactional applications with heavy volumes of data changes can benefit from forced parameterization by the virtue of increased reuse of query execution plans. Parameterization takes place at individual statement level, so each batch can contain multiple parameterized statements. Forced parameterization causes every single literal passed to a query to be translated into a parameter during compilation. The exceptions to this rule include:
You should also note that not all clauses of the parameterized statement can be parameterized. In particular the following portions of SQL statements CANNOT be parameterized:
Forced parameterization can speed up some queries because it increases the likelihood of execution plan re-use. On the other hand, it can hinder performance of other queries because the query optimizer might not utilize the index on an indexed view or computed column since literals are translated into parameters. Furthermore, when you set the parameterization option to "forced", all execution plans that aren't currently compiling / recompiling / referenced are flushed out of the procedure cache. It is recommended to test the application thoroughly with forced parameterization turned on prior to using this option in production environment. |