• <legend id='Bkh0t'><style id='Bkh0t'><dir id='Bkh0t'><q id='Bkh0t'></q></dir></style></legend>
    <tfoot id='Bkh0t'></tfoot>

  • <i id='Bkh0t'><tr id='Bkh0t'><dt id='Bkh0t'><q id='Bkh0t'><span id='Bkh0t'><b id='Bkh0t'><form id='Bkh0t'><ins id='Bkh0t'></ins><ul id='Bkh0t'></ul><sub id='Bkh0t'></sub></form><legend id='Bkh0t'></legend><bdo id='Bkh0t'><pre id='Bkh0t'><center id='Bkh0t'></center></pre></bdo></b><th id='Bkh0t'></th></span></q></dt></tr></i><div id='Bkh0t'><tfoot id='Bkh0t'></tfoot><dl id='Bkh0t'><fieldset id='Bkh0t'></fieldset></dl></div>
      <bdo id='Bkh0t'></bdo><ul id='Bkh0t'></ul>

        <small id='Bkh0t'></small><noframes id='Bkh0t'>

        SQL Server:在 proc 定义中使用“WITH RECOMPILE"的影响?

        时间:2023-10-26
      1. <i id='aT32U'><tr id='aT32U'><dt id='aT32U'><q id='aT32U'><span id='aT32U'><b id='aT32U'><form id='aT32U'><ins id='aT32U'></ins><ul id='aT32U'></ul><sub id='aT32U'></sub></form><legend id='aT32U'></legend><bdo id='aT32U'><pre id='aT32U'><center id='aT32U'></center></pre></bdo></b><th id='aT32U'></th></span></q></dt></tr></i><div id='aT32U'><tfoot id='aT32U'></tfoot><dl id='aT32U'><fieldset id='aT32U'></fieldset></dl></div>

        <legend id='aT32U'><style id='aT32U'><dir id='aT32U'><q id='aT32U'></q></dir></style></legend>

        • <bdo id='aT32U'></bdo><ul id='aT32U'></ul>
              <tbody id='aT32U'></tbody>

                <small id='aT32U'></small><noframes id='aT32U'>

                1. <tfoot id='aT32U'></tfoot>
                  本文介绍了SQL Server:在 proc 定义中使用“WITH RECOMPILE"的影响?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我对存储过程的 WITH RECOMPILE 选项的理解通常仅限于使用带有单个存储过程调用的子句作为尾随参数:

                  My understanding of the WITH RECOMPILE option with stored procedures is generally limited to using the clause with a single stored proc call as a trailing parameter:

                  exec sp_mystoredproc 'Parameter1', 2, '1/28/2011' with recompile
                  

                  在实际的 proc 定义中包含 WITH RECOMPILE 有什么影响?这会在每次执行时重新编译 proc 吗?还是只是在下一次更改 proc 时?

                  What are the effects of including WITH RECOMPILE in the actual proc definition? Does this recompile the proc every time it's executed? Or just the next time the proc is altered?

                  示例:

                  CREATE PROCEDURE [dbo].[sp_mystoredproc]
                      (@string1           varchar(8000)
                      ,@int2              int = 2
                      ,@dt_begin          DATETIME
                      with recompile
                  AS
                  ... proc code ...
                  

                  推荐答案

                  这使得 proc 每次运行时都会重建所有查询的计划.

                  This makes the proc rebuild the plans of all queries every time it's run.

                  proc 参数的值会影响过滤器的选择性.

                  Useful it the values of the proc parameters affect the filter selectivity.

                  比如说,这个查询的最佳计划:

                  Say, the optimal plan for this query:

                  SELECT  *
                  FROM    orders
                  WHERE   order_date BETWEEN @begin_report AND @from_report
                  

                  如果日期范围很大,将进行完整扫描如果日期范围很小,则进行索引扫描.

                  will be a full scan if the date range is large or an index scan if it's small.

                  使用 WITH RECOMPILE 创建,proc 将在每次执行时构建计划;如果没有,它将坚持一个计划(但会节省重新编译本身的时间).

                  Created using WITH RECOMPILE, the proc will build the plan on each execution; without one, it will stick to a single plan (but will save time on recompilation itself).

                  这个提示通常用于处理大量数据和做复杂报告的procs,当整体查询时间很大,重建计划的时间与更好的计划节省的时间相比可以忽略不计.

                  This hint is usually used in procs processing large volumes of data and doing complex reports, when the overall query time is large and time for rebuilding the plan is negligible compared with the time saved by a better plan.

                  这篇关于SQL Server:在 proc 定义中使用“WITH RECOMPILE"的影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何使用 Doctrine2 和 MySQL 执行存储过程 下一篇:使用 SQL Server 的输出参数调用 Oracle 存储过程

                  相关文章

                  1. <i id='udVFZ'><tr id='udVFZ'><dt id='udVFZ'><q id='udVFZ'><span id='udVFZ'><b id='udVFZ'><form id='udVFZ'><ins id='udVFZ'></ins><ul id='udVFZ'></ul><sub id='udVFZ'></sub></form><legend id='udVFZ'></legend><bdo id='udVFZ'><pre id='udVFZ'><center id='udVFZ'></center></pre></bdo></b><th id='udVFZ'></th></span></q></dt></tr></i><div id='udVFZ'><tfoot id='udVFZ'></tfoot><dl id='udVFZ'><fieldset id='udVFZ'></fieldset></dl></div>

                      <tfoot id='udVFZ'></tfoot>

                    1. <small id='udVFZ'></small><noframes id='udVFZ'>

                    2. <legend id='udVFZ'><style id='udVFZ'><dir id='udVFZ'><q id='udVFZ'></q></dir></style></legend>
                        <bdo id='udVFZ'></bdo><ul id='udVFZ'></ul>