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).
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.