您好,我是小DAI,专注于数据库管理员相关的技术问答,请问有什么可以帮您?

sp_cmp_qplans

语法


sp_cmp_qplans <id1>, <id2>

参数

<id1>, <id2>

是两个抽象计划的 ID。

示例

示例 1

将抽象计划 411252620 和 1383780087 进行比较:


sp_cmp_qplans 411252620, 1383780087

The queries are the same.
The query plans are the same.

示例 2

将抽象计划 2091258605 和 647777465 进行比较:


sp_cmp_qplans 2091258605, 647777465

The queries are the same.
The query plans are different.

用法

使用 sp_cmp_qplans 时,还存在一些其它注意事项:

  • sp_cmp_qplans 比较查询、抽象计划和两个抽象计划的散列键,并报告查询是否相同以及计划是否相同。对于查询,它输出以下消息之一:

    1) The queries are the same.

    2) The queries are different.

    3) The queries are different but have the same hash key.

    它将输出抽象计划的以下消息之一:

    1)The query plans are the same.

    2) The query plans are different.

  • sp_cmp_qplans 也将输出返回状态,显示比较的结果。状态值 1、2 和 10 是附加值。状态值及其含义如下:

    0 – 查询文本和抽象计划相同。

    +1 – 查询和散列键不同。

    +2 – 查询不同但散列键相同。

    +10 – 抽象计划不同。

    100 – 一个或两个计划 ID 不存在。

  • 要查找计划的 ID,请使用 sp_help_qpgroup 或 sp_find_qplan。计划 ID 也可以由 create plan 返回并包含在 showplan 输出中。