Skip to content

Feature: Per-statement timing with -p flag #621

@dlevy-msft-sql

Description

@dlevy-msft-sql

Summary

Add per-statement timing information when using the -p flag, showing execution time for each individual statement in a batch rather than just the batch total.

Use Case

  • Identify slow queries within multi-statement batches
  • Performance tuning and optimization
  • Query profiling during development

Current Behavior

With -p flag, only the total batch execution time is shown:

Network packet size (bytes): 4096
1 xact(s):
Clock Time (ms.): total       150

Proposed Behavior

Show timing for each statement within a batch:

-- Statement 1: SELECT * FROM users
Clock Time (ms.): 45

-- Statement 2: SELECT * FROM orders  
Clock Time (ms.): 105

Network packet size (bytes): 4096
2 xact(s):
Clock Time (ms.): total       150

Implementation Notes

  • Track timing at the statement level, not just batch level
  • Consider making this an optional enhancement to -p (e.g., -p2 for verbose timing)
  • Leverage existing timing infrastructure used for :PERFTRACE

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions