sp_find_qplan

Description

Finds an abstract plan, given a pattern from the query text or plan text.

Syntax

sp_find_qplan pattern [, group ]

Parameters

pattern

is a string to find in the text of the query or abstract plan.

group

is the name of the abstract plan group.

Examples

Example 1

Reports on all abstract plans that have the string “from titles” in the query:

sp_find_qplan "%from titles%"
gid id          text
--- ----------- --------------------------------------------------
2   921054317 select count(*) from titles
2   921054317
         ( plan
        ( i_scan t_pub_id_ix titles )
        ( )
)
( prop titles
        ( parallel 1 )
        ( prefetch 16 )
        ( lru )
)
5   937054374 select type, avg(price) from titles group by type
5   937054374
         ( plan
        ( store Worktab1
                ( i_scan type_price titles )
        )
        ( t_scan ( work_t Worktab1 ) )
)
( prop titles
        ( parallel 1 )
        ( prefetch 16 )
        ( lru )

Example 2

Finds all plans that include a table scan operator:

sp_find_qplan "%t_scan%"

Example 3

Uses the range pattern matching to look for strings such as “table1”, “table2”, and so forth, in plans in the dev_plans group:

sp_find_qplan "%table[0-9]%", dev_plans

Usage

Permissions

The permission checks for sp_find_qplan differ based on your granular permissions settings.

Granular permissions enabled

With granular permissions enabled, you must be a user with manage abstract plans privilege or monitor qp performance privilege.

Any user can execute sp_find_qplan to find and display report plans that they own.

Granular permissions disabled

With granular permissions disabled, you must be the database owner or a user with sa_role.

Any user can execute sp_find_qplan to find and display report plans that they own.

Auditing

Values in event and extrainfo columns from the sysaudits table are:

Event

Audit option

Command or access audited

Information in extrainfo

38

exec_procedure

Execution of a procedure

  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – All input parameters

  • Proxy information – Original login name, if set proxy in effect

See also

System procedures sp_help_qpgroup, sp_help_qplan