Freitag, 5. Juni 2020

one purpose of trm files

Since Oracle version 11g, beside trace files (.trc) there are also trace metadata files (.trm). They are often quite small. Still often they are seen as useless and cleaned up. 

Oracle Support Document TRM Trace Files Getting Generated (Doc ID 750982.1) claims:

The metadata in .trm files describes the trace records stored inside of .trc trace files.
The Trace metadata allows tools, such as Adrci, to post-process the trace information.

By deleting the .trm file, you make the .trc file unusable for post processing from ADR using ADRCI tool.
One additional purpose is to assist in proper results in V$DIAG_TRACE_FILE_CONTENTS.

Here a small example of a SQL_TRACE file: 
In a text editor, you can see the line numbers and it's content:



But V$DIAG_TRACE_FILE_CONTENTS shows it slightly different:


You can see a gap between LINE_NUMBER 28 and 40. 
The full payload of line 40 is 
declare
    stm varchar2(32767) := 'select payload from v$diag_trace_file_contents where trace_filename = ''cdb1_ora_3435.trc'' and rownum = 1';
    app varchar2(1000) := ' and trace_filename = ''cdb1_ora_3435.trc''';
    val varchar2(4000);
    n number;
begin
    for i in 1 .. 500 loop
        stm := stm || app;
    end loop;
    execute immediate stm into val;
end;

The full content of original lines 29..40 is proposed in only 1 line here - with the real line number of it's last line as LINE_NUMBER

This can be useful, e.g. to identify the SQL at one entity, instead of parsing the result set line by line. 
It is one of several ways how trace metadata files help interpreting the trace files content. 



If the .trm file is removed, the result looks slightly different: 


every line on the tracefile is a real line in V$DIAG_TRACE_FILE_CONTENTS
There is also no COMPONENT_NAME visible. 
The simple content if the tracefile without any additional metadata or interpretation.

Keine Kommentare: