Posts mit dem Label xml werden angezeigt. Alle Posts anzeigen
Posts mit dem Label xml werden angezeigt. Alle Posts anzeigen

2023-09-23

changes in SQL real time monitor report in 23c free

I like Oracle SQL real time monitor reports as they contain a huge amount of valuable information and can be viewed and transferred very simple. 
It's content increased over time - and as oracle updates the java script libraries to generate a nice view, sometimes the same report reveals even more details when you open the same old report later! So it was a kind of downer when I saw the amount of content decreasing since 19c! Here some screenshots what changed: 

19c:


21c:

Here the report misses Activity and Metrics. 

23c free: 

This report misses Activity, Metrics and Outlines - compared to 19c. 


That's quite sad! 
And this information is really missing in the html file - so we can't blame the java script library for this. 

The data is stored as a XML structure in the html report. But to be readable for humans, we need to decode it first  - at least I can't read this directly:



  <script id="fxtmodel" type="text/xml">
   <!--FXTMODEL-->
   <report db_version="19.0.0.0.0" elapsed_time="3.23" cpu_time="3.21" cpu_cores="4" hyperthread="N" con_id="3" con_name="PDB1" timezone_offset="0" packs="2" service_type="0" encode="base64" compress="zlib">
    <report_id><![CDATA[/orarep/sqlmonitor/main%3fsql_exec_id%3d16777216%26sql_exec_start%3d09%3a23%3a2023%2012%3a42%3a10%26sql_id%3d2u4jc5hhwhc7n]]></report_id>
                eAHtffl348aR8O/+K/AxTnZmP9siDl6OxLc6OI4cHWMdSbz79vFRFCTRpkiZBOfI
X79VfaAPNIAGCFIaDbz7MiLQ6Kvu6qrq3eUf0+HjfDaJ5ovhInyaLyLnQ7hYTuaz
vUbwQ7PhLD8vb0dRuNdo9nY8f8drer7jej8G3o9ut9H/xnF26WfDp9Fi9BhG8DE+
hefY9eS2762C38ath4ePD+PObHeHPRVNwk/hGNu57U6n47lt2oQ/1doto9Ei6ien
...

Luckily it claims what it is doing: encode="base64" compress="zlib" And so Franck Pachot already cared about a way to decode it.

I slightly adapted it to my laptops needs:

xmllint --xpath '/html/body/script/report' 19c.html  | grep -v report | base64 -id | \
python3 -c "import zlib,sys;sys.stdout.buffer.write(zlib.decompress(sys.stdin.buffer.read()))"  > 19c.xml


The missing sections in 21c and 23cfree are


Activity:

   <activity_sampled>
    <activity class="Cpu">1</activity>
  </activity_sampled>
  <activity_detail start_time="09/23/2023 12:42:10" end_time="09/23/2023 12:42:19" first_sample_time="09/23/2023 12:42:10" last_sample_time="09/23/2023 12:42:10" duration="1" sample_interval="1" bucket_interval="1" bucket_count="10" bucket_duration="10" cpu_cores="4" total_cpu_cores="4" hyperthread="N">
    <bucket number="1">
      <activity class="Cpu" line="77">1</activity>
    </bucket>
  </activity_detail>


Metrics:

  <stattype name="metrics" cpu_cores="4" hyperthread="N">
    <stat_info>
      <stat id="1" name="nb_cpu"/>
      <stat id="2" name="nb_sess"/>
      <stat id="3" name="reads" unit="per_sec"/>
      <stat id="4" name="writes" unit="per_sec"/>
      <stat id="5" name="read_kb" unit="bytes_per_sec" factor="1024"/>
      <stat id="6" name="write_kb" unit="bytes_per_sec" factor="1024"/>
      <stat id="7" name="interc_kb" unit="bytes_per_sec" factor="1024"/>
      <stat id="8" name="cache_kb" unit="bytes_per_sec" factor="1024"/>
      <stat id="9" name="pga_kb" unit="bytes" factor="1024"/>
      <stat id="10" name="tmp_kb" unit="bytes" factor="1024"/>
    </stat_info>
    <buckets bucket_interval="1" bucket_count="10" start_time="09/23/2023 12:42:10" end_time="09/23/2023 12:42:19" duration="10">
      <bucket bucket_id="1">
        <stat id="1" value=".26"/>
        <stat id="3" value="494"/>
        <stat id="5" value="4008"/>
        <stat id="7" value="4008"/>
        <stat id="8" value="154224"/>
        <stat id="9" value="12586"/>
      </bucket>
    </buckets>
  </stattype>

Outlines:

        <outline_data>
          <hint><![CDATA[IGNORE_OPTIM_EMBEDDED_HINTS]]></hint>
          <hint><![CDATA[OPTIMIZER_FEATURES_ENABLE('19.1.0')]]></hint>
          <hint><![CDATA[DB_VERSION('19.1.0')]]></hint>
          <hint><![CDATA[ALL_ROWS]]></hint>
          <hint><![CDATA[OUTLINE_LEAF(@"SEL$3")]]></hint>
          <hint><![CDATA[OUTLINE_LEAF(@"SEL$4")]]></hint>
          <hint><![CDATA[OUTLINE_LEAF(@"SEL$11")]]></hint>
...
  



It would be a quite depressing post when the story ends here. 
But there is hope:

In 23c_free Oracle introduced new parameters for _fix_control. 
This one is really helpful: 

350691421QKSFM_CBO_35069142use ADVANCED format for plan display in SQL Monitor

With a simple 

alter session set "_fix_control"='35069142:1';

My Report shows much more content now:


Activity, Metrics and Outlines are back and new content is visible also: SQL Analysis. 

This contains of 2 sections: 

SQL Analysis

Line ID
Query Block
Message
 1
SEL$43The query block has 2 cartesian products which may be expensive. Consider adding join conditions or removing the disconnected tables or views.
 13
SEL$E029B2FF / "O"@"SEL$5"The following columns have predicates which preclude their use as keys in index range scan. Consider rewriting the predicates.
  "NAME"
  "TYPE#"
 45
SEL$D0BBB93D / "O"@"SEL$19"The following columns have predicates which preclude their use as keys in index range scan. Consider rewriting the predicates.
  "NAME"
  "TYPE#"
 77
SEL$B2BBC534 / "O"@"SEL$33"The following columns have predicates which preclude their use as keys in index range scan. Consider rewriting the predicates.
  "NAME"
  "TYPE#"
selected


which comes from the XML section 
      <sqla>
        <sec id="1">
          <n><![CDATA[SEL$43]]></n>
          <msg>
            <m li="1"><![CDATA[The query block has 2 cartesian products which may be ]]></m>
            <m li="2"><![CDATA[expensive. Consider adding join conditions or removing the ]]></m>
            <m li="3"><![CDATA[disconnected tables or views.]]></m>
          </msg>
        </sec>
        <sec id="13">
          <n><![CDATA[SEL$E029B2FF / "O"@"SEL$5"]]></n>
          <msg>
            <m li="1"><![CDATA[The following columns have predicates which preclude their ]]></m>
            <m li="2"><![CDATA[use as keys in index range scan. Consider rewriting the ]]></m>
            <m li="3"><![CDATA[predicates.]]></m>
            <m li="4" list="Y"><![CDATA["NAME"]]></m>
            <m li="5" list="Y"><![CDATA["TYPE#"]]></m>
          </msg>
        </sec>
        <sec id="45">
          <n><![CDATA[SEL$D0BBB93D / "O"@"SEL$19"]]></n>
          <msg>
            <m li="1"><![CDATA[The following columns have predicates which preclude their ]]></m>
            <m li="2"><![CDATA[use as keys in index range scan. Consider rewriting the ]]></m>
            <m li="3"><![CDATA[predicates.]]></m>
            <m li="4" list="Y"><![CDATA["NAME"]]></m>
            <m li="5" list="Y"><![CDATA["TYPE#"]]></m>
          </msg>
        </sec>
        <sec id="77">
          <n><![CDATA[SEL$B2BBC534 / "O"@"SEL$33"]]></n>
          <msg>
            <m li="1"><![CDATA[The following columns have predicates which preclude their ]]></m>
            <m li="2"><![CDATA[use as keys in index range scan. Consider rewriting the ]]></m>
            <m li="3"><![CDATA[predicates.]]></m>
            <m li="4" list="Y"><![CDATA["NAME"]]></m>
            <m li="5" list="Y"><![CDATA["TYPE#"]]></m>
          </msg>
        </sec>
      </sqla>



Hint Usage Issues

Line ID
Query Block
Hint
Hint Status
 2
SEL$1materialize Applied Successfully
 34
SEL$15materialize Applied Successfully
 66
SEL$29materialize Applied Successfully

with the XML  
      <hreport>
        <leg>
          <t>3</t>
        </leg>
        <sec id="2">
          <n><![CDATA[SEL$1]]></n>
          <h><![CDATA[materialize]]></h>
        </sec>
        <sec id="34">
          <n><![CDATA[SEL$15]]></n>
          <h><![CDATA[materialize]]></h>
        </sec>
        <sec id="66">
          <n><![CDATA[SEL$29]]></n>
          <h><![CDATA[materialize]]></h>
        </sec>
      </hreport>

We will see how 35069142 evolves over time.




2018-07-23

enabling Database Vault on e-business RAC database

Right now I'm in a process to setup Database Vault for an E-Business suite database. This is a 2 node RAC cluster.
The DB is 12.1.0.2 with April 17 BP.

As the DB exists already, I followed How To Enable Database Vault in a 12c database ? (Doc ID 2112167.1).
Everything looks smooth, but unfortunately, at the Configuration of DV
exec dvsys.configure_dv('DVOWNER','DVMANAGER');
failes with
ERROR at line 1: 
ORA-47500: Database Vault cannot be configured. 
ORA-06512: at "DVSYS.CONFIGURE_DV", line 23 
ORA-06512: at "DVSYS.CONFIGURE_DV", line 72 
ORA-06512: at line 2 

ORA-47500 tells
47500, 00000, "Database Vault cannot be configured."
// *Cause: The Database Vault configuration failed because some Database Vault  
//         objects were missing.
// *Action: Run the dvremov.sql script to remove Database Vault and then
//          reinstall Database Vault.

This was the first try: remove DV and start again.
Nothing changed.


Some research on MOS led to Known Issues In A Database Vault Environment (Doc ID 2330775.1)
there the explanation for ORA-47500 is:

Cause: There are many invalid objects in the database.

Solution: Run $ORACLE_HOME/rdbms/admin/utlrp.sql to validate the invalid objects

So all invalid objects were removed/fixed and - DV enabled again.
With same error.


A lot more investigation and a SR was required here.

When catmac.sql was run it completed and didn't show any hints it failed at the end.
Especially register DB and it's validation were shown successful:
SQL> DECLARE
  2      num number;
  3  BEGIN
  4      dbms_registry.loaded('DV');
  5      SYS.validate_dv;
  6  END;
  7  /

PL/SQL procedure successfully completed.


After a lot more investigation, an issue in the (manually activated) spool of catmac.sql was found:
ERROR at line 1:
ORA-31011: XML parsing failed
ORA-19213: error occurred in XML processing at lines 49
LPX-00217: invalid character 21 (U+0015)
ORA-06512: at "DVSYS.DBMS_MACADM", line 160
ORA-06512: at line 2
and this error stack leads to Installation Of Database Vault Fails With ORA-19213, LPX-00217: Invalid Character 21 (U+0015) (Doc ID 2324871.1)
As so often: the problem looks obvious, but only after it was found.


The problem is the environment variable
ORA_NLS10=<ORACLE_HOME>/nls/data/9idata
Which is a requirement for Oracle E-business Suite.

Here RAC has it fair share of complexity as this environment is not (only) defined in a .bash_profile or similar, but also in cluster registry:
srvctl getenv database -d <DB_UNIQUE_NAME>
EBSSIB01_SITE1:
ORA_NLS10=<ORACLE_HOME>/nls/data/9idata

The fix was to disable this setting:
srvctl unsetenv database -d <DB_UNIQUE_NAME> -t ORA_NLS10
restart all instances
and now successfully enable DV at last!

Of course, afterwards ORA_NLS10 must be set again
srvctl setenv  database -d <DB_UNIQUE_NAME> -t "ORA_NLS10=<ORACLE_HOME>/nls/data/9idata"
and instances restarted once more.

2015-01-07

checking suspicious bind variables in v$sql_monitor

In my current company we try to stabilize the performance of our Peoplesoft application. So on a more or less regular base I get a call to investigate as "it" is "slow" now.
During my research I found one error-pattern I'd like to show here: SQLs which where parsed for very selective BINDs (like customer-id) are executed with a single space (" ") as bind.
Unfortunately in Peoplesoft this character is used similar to NULL - so when it doesn't know what value to store, a space is used.
In general such BINDs lead to improper NESTED LOOPs.
Every time I found such executions, they where accepted as defect by development.

I'm in the lucky position to have tuning pack licensed, so I can use real time sql monitoring. That's very handy as I can save the a SQL in question together with a lot of infos (client, machine, module, start-time, BINDs, ...) in a html file and save it for later analysis/forward.

As v$sql_monitor shows specific executions, and it has all the BINDs stored as well, I can use it now to find other suspicious statements. So this little statement gives me some infos where to look closer:

SELECT sql_id, 
       name, 
       '--' || value || '--' 
FROM   (SELECT KEY, 
               sql_id, 
               xmltype.Createxml(binds_xml) confval 
        FROM   v$sql_monitor) v, 
       XMLTABLE('/binds/bind' passing v.confval 
                COLUMNS name  VARCHAR2(25)   path '@name', 
                        value VARCHAR2(4000) path '.'      ) 
WHERE  value = ' ' 
        OR value IS NULL; 
with an output like this:
SQL_ID        NAME                      VALUE
------------- ------------------------- -----
63pw6bqt84793 :2                        -- -- 

Please do NOT start with this statement when your application is "slow" - not even when it's Peoplesoft.