Identifying statements from v$sql
lh, June 14, 2018 - 7:08 am UTC
Hi
For 'batch' type programs one can use setting of module to identify sql statements.( dbms_application_info.set_module)
But if this oltp-type system setting module before executing each service would require strong coding discipline. (what actually is performance impact for setting module/action? Also dbms_application_info is not 'stack' based, so using this for nested calls can cause problems).
I have found it usefull to recommend that these oltp services would use hint as way to identify where sql-statement originated. Helps solving performance problems.
lh
whats in a name?
Racer I., June 14, 2018 - 10:58 am UTC
Hi,
We use both approaches.
SELECT /*+ FULL(a) "package/class/script here_i_am.sql" */
The /*+ stops Oracle (in PLSQL) from stripping the comments (bad habit) as the OP noticed. We never had (knowingly) any problems with our comments becoming hints, but the quoting and placing last might help with that.
It's also explicitely meant for production, so problematic statement can quickly be connected with their source. Say via fisheye. Developer discipline is mostly addressed by code generation.
We also use dbms_application_info : module/action/clientinfo. They are somewhat short though, so we use IDs mostly (webservices, batches und messages have those). This is done via the corresponding frameworks, so requires no developer disclipine except for occasional manual scripting. This works well with ASH/AWR.
Granularity below that is mostly handled via java-/plsql-stackframes and logging.
regards,
June 15, 2018 - 1:12 am UTC
Certainly I'm a big fan of exploiting module/action/client_info to track SQL