This question was posted today on the OTN SQL-PL/SQL Forum:
For a given schema and object name, the following information is provided through this view:
So suppose you need to identify any program units that may have been accidentally compiled with an optimization level below 2 (the default, aggressive optimization, which can only be improved upon by level 3, which turns on inlining of subprograms globally).
No problem!
Or how about: for which program units has identifier information been gathered for PL/Sscope analysis?
I offer a LiveSQL script to help you take full, quick advantage of this data dictionary view.
Is there a way, after compilation, to detect what level of optimization was used? Perhaps you have something already in production, and you just want to find some candidates for recompile (but not necessarily any changes in the source) with increased optimization level.The answer is: Yes! Just run a query against the ALL_PLSQL_OBJECT_SETTINGS data dictionary view (or the USER_PLSQL_OBJECT_SETTINGS, to see information only about program units you own).
For a given schema and object name, the following information is provided through this view:
So suppose you need to identify any program units that may have been accidentally compiled with an optimization level below 2 (the default, aggressive optimization, which can only be improved upon by level 3, which turns on inlining of subprograms globally).
No problem!
SELECT * FROM user_plsql_object_settings p WHERE p.plsql_optimize_level < 2
Or how about: for which program units has identifier information been gathered for PL/Sscope analysis?
SELECT * FROM user_plsql_object_settings p WHERE plscope_settings = 'IDENTIFIERS:ALL'
I offer a LiveSQL script to help you take full, quick advantage of this data dictionary view.
Hi Steven,
ReplyDeleteis there a way to see how the compiled code looks like, after optimization (level 2 or 3) took place?
regards
Sven
No. This question has come up a lot over the years. First, the compiled code is no longer PL/SQL, so it's value to developers would be pretty limited. In addition, the whole point of automatic optimization is to relieve YOU of the need to pay attention to things like loop invariants. Instead, you concentrate on implementing requirements and writing maintainable code.
Delete