Expose source module [object_id] / @@PROCID and [database_id] in <Batch> element of Execution Plan
In execution plans (at least the XML version of them), please add attributes to the <Batch> element for "ObjectId" and "DatabaseId" that are populated with the values for the T-SQL module that is the source for that particular batch (stored procedure, trigger, scalar UDF, multi-statement TVF).
Ideally the "ObjectId" attribute would contain the same value found in
@@PROCID, meaning that for scenarios that do not naturally have an
object_id (views, inline TVFs, dynamic SQL / ad hoc queries), it would contain the value that is similar to the QueryHash and is specific to the bytes of that query text.
This will greatly assist in both debugging and query tuning in two ways:
finding the source of the query, especially when multiple modules are involved.
associating which statements in a plan are coming from the same module, especially when modules contain multiple statements, and triggers and/or sub-modules are referenced.