SQL trace or audit?

Dear friends, DBA,

Version of DB - 11.1.0.7

I have a situation where I have to trace SQLs run by a specific user. The user executes the action click in front end application and I need to follow what SQLs it is running in the database.

This is not feasible with the tracing session level that the session ID changes in the course of the series click and go the actions performed by this user in the application.

What would be an apt approach to follow the action performed by the user on the database? An option of the audit?

Thank you.

within the LOGON trigger you could do as below based on the value of the USER

ALTER SESSION SET SQL_TRACE = TRUE;

Tags: Database

Similar Questions

  • SQL trace only on a single node of RAC

    Hello

    I try to do a SQL Trace...

    But if I activate the Trace, only the first node is drawn. But I want to find the second node.

    I tried things a.

    exec dbms_monitor. DATABASE_TRACE_ENABLE (instance_name = > 'C2DB06S1I2');

    or

    ALTER SYSTEM SET sql_trace = TRUE SCOPE = memory sid ='* ';

    or

    ALTER SYSTEM SET sql_trace = TRUE SCOPE = memory sid = "c2db06s1i2";

    But there is no Tracefiles or Tracefiles are only on the first node.

    We use the Oracle on Oracle Linux 6.3 11.2.0.3 database

    BECAUSE with two nodes

    Any ideas?

    Thanks for your help

    Jens

    Hello

    Thanks for all your replies.

    Everything is fine. Oracle has done right.

    I was stupid to realize that I was in the right folder.

    On the second node, I looked in the diag_dest to a different database.

    Thank you

    Jens

  • SQL trace

    Hello

    I know how to generate sql trace of user session that follows.

    SQL > ALTER SESSION SET EVENTS 10046 trace name forever, context level 12';

    SQL > alter session set tracefile_identifier = "xyz";

    I want to know how to generate sql trace system (or any other account) from different machine when working some of the user databases with SQL and PLSQL on another computer and access the database.

    concerning

    EXEC DBMS_SYSTEM.set_sql_trace_in_session (211, 23084, TRUE);

    EXEC DBMS_SYSTEM.set_ev (211, 23084, 10046, 12, 'test');

    You do not use both.  Use set_sql_trace_in_session (preferred) or set_ev (not officially supported).

    But I want to find other user sessions.

    Yes, an account with EXECUTE on DBMS_SYSTEM (for example with the DBA role) can use dbms_system.set_sql_trace_in_session to enable tracing to another session.

    Note that the name of the trace file is by processID of BONES of the dedicated server process (i.e. the SPID in V$ PROCESS for this session)

    Hemant K Collette

  • Query SQL trace parameters

    Hello

    I send you SQL queries to Oracle via JDBC, and I want to debug those with SQL trace SQL queries.
    My problem is when I want to display the trace through tkprof, my queryies files do not display settings.

    For example: SELECT * FROM MaTable WHERE MyColumn =: 1

    I would like to see the value of: 1.

    How can I do?

    Thank you

    user610868 wrote:
    Hello

    I send you SQL queries to Oracle via JDBC, and I want to debug those with SQL trace SQL queries.
    My problem is when I want to display the trace through tkprof, my queryies files do not display settings.

    For example: SELECT * FROM MaTable WHERE MyColumn =: 1

    I would like to see the value of: 1.

    How can I do?

    Thank you

    trace level must be set to 4 to capture the values of BIND variables

  • Disable SQL TRACE seems to not work

    Hello

    To find the SQL TRACE file, I have executed the SQL below:

    SQL > alter system set sql_trace = true;

    Modified system.

    SQL > alter system set timed_statistics = true;

    Modified system.

    SQL > alter system set max_dump_file_size = unlimited.

    Modified system.

    SQL > alter system set tracefile_identifier = "DAILY_JOB2";

    Modified system.

    SQL > alter system set events 10046 name context forever, trace level 12';

    Modified system.

    and then this command

    SQL > alter system set sql_trace = false;

    Modified system.

    But still, occurs, even after 20-30 minutes SQL trace files. No idea why?

    Need to stop and restart the DB.

  • 11g SQL trace

    Hello, I need to configure SQL Trace to the instsnce level. I need capture query plans and bind values. I think I set SQL_TRACE = TRUE. It will capture all the info I need? Are the trace flags, that I can set as well at the level of the system?

    Thank you

    David

    JesusLuvR wrote:
    How to set the trace at the system level event?

    See my post on this topic:
    Re: SQL_TRACE helps newbie in oracle

    The command you're looking for is this one:

    ALTER SYSTEM SET EVENTS '10046 TRACE NAME CONTEXT FOREVER, LEVEL 12';
    

    Do not specify the scope. Note that you can use a logon trigger to create a trace for a specific user or application.

    The next question is to know how to read the file, see my post on this topic:
    Re: a few 10046 traceing questions...

    Charles Hooper
    IT Manager/Oracle DBA
    K & M-making Machine, Inc.

  • Address of the instantiation of the cursor in the SQL trace files > = 11.2.0.2

    Oracle Doc ID 11677061.8 mentions in 11.2.0.2 10046 trace / SQL_TRACE displays the address of the instantiation after the # rather than the number of cursor.

    Can someone explain what a "address instantiation" is and how to use it to identify the sliders in the trace of the files in an improvement on number of cursor.

    I have a theory that it may be useful when dealing with accumulated from several trace files using trcsess trace data.

    For the most part, I'm just curious to see if I can improve my performance skills by exploiting this change.  I can't find a single reference in the article or the blog describing the change.

    An example of the largest number of cursor that I see these days.

    PARSING IN CURSOR #48003855878616 len=65 dep=0 uid=370 oct=6 lid=370 tim=1366907498174148 hv=1477430740 ad='209f99a028' sqlid='40hwrntc0zmfn'

    ANALYSIS #48003855878616:c = 0, e = 4842, p = 0, cr = 0, cu = 0, set = 0, r = 0, dep = 0, og = 1, plh = 0, tim = 1366907498174146


    Pre 11.2.0.2 what it would look like


    PARSING IN CURSOR #3 len=65 dep=0 uid=370 oct=6 lid=370 tim=1366907498174148 hv=1477430740 ad='209f99a028' sqlid='40hwrntc0zmfn'

    ANALYSIS # 3: c = 0, e = 4842, p = 0, cr = 0, cu = 0, = 0, r = 0, dep = 0, og = 1, plh = 0, tim = 1366907498174146



    Here's what I read on the subject in 2010:

    The problem is that with the restructured cursor caching in 11g a statement executed again would come by number of different cursor for each run. As the number of cursor and the sqltext did not since the last use of the slider, the sqltext was printed for each execution of a cursor. It's a significant problem for applications like Oracle E-Business, where is typical SQL statement it is many thousands of characters. In some cases, this has increased the size of the file trace of an order of magnitude, and I'm sure it could be even worse.

    The solution was to pass the handle of the cached cursor (which is probably the address) and display instead of the cursor number. This should mean that the text is printed only on the first analysis of the SQL statement and the size of the trace file goes back to something reasonable.

    I believe you can "join" these new id values cursor from a trace file in a column of address in v$ sql, but I have not checked myself.

    I do not think that the change was intended to give the advantage of trcsess you are suspect, but it could turn out to be useful for this.

  • SQL trace session

    Hi all


    I have read a few articals on how to follow-up of oracle sessions and I have a few question

    I use the 10g database

    trace vs. event? different between them?


    How draw a single statement I hope give me this point in ex:
    due to I can not get the sql_id, how do I know the sql_is to specify statement?


    Thank you

    Select * from employees;
    How do I know that the above statement sql_id.

    Select sql_id in v$ sql where sql_text =' select * from employees;

  • Ask the events of trace sql result 10046 level 8 and 12

    Hi all, I read the result of events to trace sql 10046 level 8 on

    http://www.Oracle-base.com/articles/10G/SQLTrace10046TrcsessAndTkprof10g.php#trace_example

    and I do the level of Event 10046 SQL trace 8 or 12. But the results were not even, plan of execution does not appear

    How to make the execution plan appears?

    How to make the execution plan appears?

    TKProf trace_results.txt .trc explain = name of user and password

  • is trace SQL - possible to appoint the output trace file?

    Hello

    I put DBMS_SYSTEM. SET_SQL_TRACE_IN_SESSION in my database. This is the version 10.2 running on Linux.
    Now, I want to display the trace file using tkprof. It is in my directory in $ORACLE_BASE/admin/SID/udump. But there are more tracks and they are all the same: instancename_ora_traceid, is very difficult to find the right one.
    Is it possible to make the sql trace file to be named by any other means?

    Thanks in advance.
    Sousou

    Hello

    Yes, you can change then what is the purpose of this
    ALTER session set tracefile_identifier = trace_file_name

    Add with the tracefile_identifier

    Select c.value | '\' || d.instance_name | "_ora_" | a.SPID | '.trc' trace_file_is_here
    v $ process a, v$ session b, v$ parameter c, v$ instance d
    where a.addr = b.paddr
    and b.audsid = userenv ('sessionid')
    and c.nom = 'user_dump_dest;

    -Pavan Kumar N

    Published by: pounet on December 9, 2008 22:23

  • scope of the audit

    I use the oracle10g database.


    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    AMT for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production



    I enabled the audit extended on my database...

    SQL > alter system set audit_trail = db, extended the scope = spfile;

    Modified system.

    Now, I want to check which ever applies any SQL SELECT on the scott schema...

    SQL > select table by scott by access audit;

    Verification succeeded.


    Now, I ran the sub query schema SCOTT

    Select count (*) from emp

    Then I went to the diagram of the system and select data in the dba_audit_trail table. It shows seven folders including my original query.



    1 * Select sql_text from dba_audit_trail
    SQL > /.

    SQL_TEXT
    --------------------------------------------------------------------------------
    SELECT USER TO TWICE
    SELECT THE SCOPE, NUMERIC_VALUE, CHAR_VALUE, DATE_VALUE OF THE SYSTEM ATTRIBUTE. PRODUCT_P
    RIUZ WHERE (UPPER('SQL*Plus') AS UPPER (PRODUCT)) AND (UPPER (USER) AS username)


    SELECT THE SCOPE, NUMERIC_VALUE, CHAR_VALUE, DATE_VALUE OF THE SYSTEM ATTRIBUTE. PRODUCT_P
    RIUZ WHERE (UPPER('SQL*Plus') AS UPPER (PRODUCT)) AND (UPPER (USER) AS username)


    SELECT CHAR_VALUE IN THE SYSTEM. PRODUCT_PRIVS WHERE (UPPER('SQL*Plus') AS UPPE
    R (PRODUCT)) AND ((UPPER (USER) LIKE USERID) OR (USERID = 'PUBLIC')) AND (UPPE

    SQL_TEXT
    --------------------------------------------------------------------------------
    (ATTRIBUTE) R = 'ROLES')

    SELECT CHAR_VALUE IN THE SYSTEM. PRODUCT_PRIVS WHERE (UPPER('SQL*Plus') AS UPPE
    R (PRODUCT)) AND ((UPPER (USER) LIKE USERID) OR (USERID = 'PUBLIC')) AND (UPPE
    (ATTRIBUTE) R = 'ROLES')

    SELECT DECODE ('A', 'A','1 ', ' 2') OF THE DOUBLE
    Select count (*) from emp

    7 selected lines.

    SQL >


    How to remove the first 6 records...

    How to find how much time this query executed in the database? dba_audit_trail doesn't have this info...

    Published by: Shrinika on March 29, 2010 13:08

    You can find the syntax and an example for the audit of a user on the following link

    http://download.Oracle.com/docs/CD/B19306_01/network.102/b14266/auditing.htm#i1008376

    Oracle does not keep track of how long all executed queries thought if you have the EM Performance Pack license, you can query the CWA to see if some executions of you query of interest have been captured.

    While a query is running, you can specify how long he has been active by querying v$ session.last_call_et. For an active session, that it is the time in seconds that the current command execution has worked. For an idle session is the time since the last command has been entered.

    For specific SQL being ran by a specific session, you can run a SQL trace to capture exactly how much time a query runs. It takes preparation. The details are in the Performance and Tuning Manual.

    HTH - Mark D Powell.

  • Help setting up a SQL query with poor performance

    Hi all

    Database version: 10.2.0.5

    I'm working on a new report to view the top users by the number of calls. The table is truncated and filled again every month with records for the previous month; It contains approximately 400 000 records.

    I created a view with the columns needed for the report; also, the two functions of view calls to determine if a phone number is assigned to multiple staffs or several departments.

    It's full again table every month:

     CREATE TABLE "VOIP"."MONTHLY_BILLING_DETAILS" 
       (    "ID" NUMBER NOT NULL ENABLE, 
        "CDRRECORDTYPE" NUMBER, 
        "G_CALLMANAGERID" NUMBER, 
        "G_CALLID" NUMBER, 
        "O_LEGCALLIDENTIFIER" NUMBER, 
        "DATETIMEORIGINATION" NUMBER, 
        "O_NODEID" NUMBER, 
        "O_SPAN" NUMBER, 
        "O_IPADDR" NUMBER, 
        "CALLINGPARTYNUMBER" VARCHAR2(50 BYTE) NOT NULL ENABLE, 
        "CALLINGPARTY_USERID" VARCHAR2(128 BYTE), 
        "O_CAUSE_LOCATION" NUMBER, 
        "O_CAUSE_VALUE" NUMBER, 
        "O_PRECEDENCELEVEL" NUMBER, 
        "O_MEDIATRANSPORTADDR_IP" NUMBER, 
        "O_MEDIATRANSPORTADDR_PORT" NUMBER, 
        "O_MCAP_PAYLOADCAPABILITY" NUMBER, 
        "O_MCAP_MAXFRAMESPERPACKET" NUMBER, 
        "O_MCAP_G723BITRATE" NUMBER, 
        "O_VCAP_CODEC" NUMBER, 
        "O_VCAP_BANDWIDTH" NUMBER, 
        "O_VCAP_RESOLUTION" NUMBER, 
        "O_VIDEOTRANSPORTADDR_IP" NUMBER, 
        "O_VIDEOTRANSPORTADDR_PORT" NUMBER, 
        "O_RSVPAUDIOSTAT" VARCHAR2(64 BYTE), 
        "O_RSVPVIDEOSTAT" VARCHAR2(64 BYTE), 
        "DESTLEGIDENTIFIER" NUMBER, 
        "DESTNODEID" NUMBER, 
        "DESTSPAN" NUMBER, 
        "DESTIPADDR" NUMBER, 
        "ORIGINALCALLEDPARTYNUMBER" VARCHAR2(50 BYTE), 
        "FINALC_PARTYNUMBER" VARCHAR2(50 BYTE), 
        "FINALC_PARTY_USERID" VARCHAR2(128 BYTE), 
        "DESTCAUSE_LOCATION" NUMBER, 
        "DESTCAUSE_VALUE" NUMBER, 
        "DESTPRECEDENCELEVEL" NUMBER, 
        "DESTMEDIATRANSPORTADDR_IP" NUMBER, 
        "DESTMEDIATRANSPORTADDR_PORT" NUMBER, 
        "DESTMCAP_PAYLOADCAPABILITY" NUMBER, 
        "DESTMCAP_MAXFRAMESPERPACKET" NUMBER, 
        "DESTMCAP_G723BITRATE" NUMBER, 
        "DV_CAP_CODEC" NUMBER, 
        "DV_CAP_BANDWIDTH" NUMBER, 
        "DV_CAP_RESOLUTION" NUMBER, 
        "DV_TRANSPORTADDR_IP" NUMBER, 
        "DV_TRANSPORTADDR_PORT" NUMBER, 
        "DESTRSVPAUDIOSTAT" VARCHAR2(64 BYTE), 
        "DESTRSVPVIDEOSTAT" VARCHAR2(64 BYTE), 
        "DATETIMECONNECT" NUMBER, 
        "DATETIMEDISCONNECT" NUMBER, 
        "LASTREDIRECTDN" VARCHAR2(50 BYTE), 
        "PKID" VARCHAR2(4000 BYTE), 
        "O_INALCALLEDPARTYNUM_PARTITION" VARCHAR2(50 BYTE), 
        "CALLINGPARTYNUM_PARTITION" VARCHAR2(50 BYTE), 
        "FINALC_PARTYNUM_PARTITION" VARCHAR2(50 BYTE), 
        "LASTREDIRECTDNPARTITION" VARCHAR2(50 BYTE), 
        "DURATION" NUMBER, 
        "O_DEVICENAME" VARCHAR2(129 BYTE), 
        "DESTDEVICENAME" VARCHAR2(129 BYTE), 
        "O_CALLTERMINATION_BEHALF" NUMBER, 
        "DESTCALLTERMINATION_BEHALF" NUMBER, 
        "O_CALLEDPARTYREDIRECT_BEHALF" NUMBER, 
        "LASTREDIRECTREDIRECT_BEHALF" NUMBER, 
        "O_CALLEDPARTYREDIRECTREASON" NUMBER, 
        "LASTREDIRECTREDIRECTREASON" NUMBER, 
        "DESTCONVERSATIONID" NUMBER, 
        "G_CALLID_CLUSTERID" VARCHAR2(50 BYTE), 
        "JOIN_BEHALF" NUMBER, 
        "COMMENTS" VARCHAR2(2048 BYTE), 
        "AUTHCODEDESCRIPTION" VARCHAR2(50 BYTE), 
        "AUTHORIZATIONLEVEL" NUMBER, 
        "CLIENTMATTERCODE" VARCHAR2(32 BYTE), 
        "O_DTMFMETHOD" NUMBER, 
        "DESTDTMFMETHOD" NUMBER, 
        "CALLSECUREDSTATUS" NUMBER, 
        "O_CONVERSATIONID" NUMBER, 
        "O_MCAP_BANDWIDTH" NUMBER, 
        "DESTMCAP_BANDWIDTH" NUMBER, 
        "AUTHORIZATIONCODEVALUE" VARCHAR2(32 BYTE), 
        "OUTPULSEDCALLINGPARTYNUMBER" VARCHAR2(50 BYTE), 
        "OUTPULSEDCALLEDPARTYNUMBER" VARCHAR2(50 BYTE), 
        "O_IPV4V6ADDR" VARCHAR2(64 BYTE), 
        "DESTIPV4V6ADDR" VARCHAR2(64 BYTE), 
        "O_VCAP_CODEC_CHAN2" NUMBER, 
        "O_VCAP_BANDWIDTH_CHAN2" NUMBER, 
        "O_VCAP_RESOLUTION_CHAN2" NUMBER, 
        "O_V_TRANSPORTADDR_IP_CHAN2" NUMBER, 
        "O_V_TRANSPORTADDR_PORT_CHAN2" NUMBER, 
        "O_V_OCHANNEL_ROLE_CHAN2" NUMBER, 
        "DV_CAP_CODEC_CHAN2" NUMBER, 
        "DV_CAP_BANDWIDTH_CHAN2" NUMBER, 
        "DV_CAP_RESOLUTION_CHAN2" NUMBER, 
        "DV_TRANSPORTADDR_IP_CHAN2" NUMBER, 
        "DV_TRANSPORTADDR_PORT_CHAN2" NUMBER, 
        "DV_CHANNEL_ROLE_CHAN2" NUMBER, 
        "DATE_CREATED" DATE, 
        "DATETIME_CONNECT" DATE, 
        "DATETIME_DISCONNECT" DATE, 
        "USERID_EMAIL_ADDRESS" VARCHAR2(100 BYTE), 
        "FROM_FULL_TELEPHONE" VARCHAR2(20 BYTE), 
        "TO_FULL_TELEPHONE" VARCHAR2(20 BYTE), 
        "FROM_EXCHANGE" VARCHAR2(7 BYTE), 
        "TO_EXCHANGE" VARCHAR2(20 BYTE), 
        "FROM_CITY" VARCHAR2(200 BYTE), 
        "FROM_STATE" VARCHAR2(2 BYTE), 
        "TO_CITY" VARCHAR2(200 BYTE), 
        "TO_STATE" VARCHAR2(2 BYTE), 
        "CALL_TYPE" VARCHAR2(10 BYTE), 
         CONSTRAINT "MONTHLY_BILLING_PK" PRIMARY KEY ("ID")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA"  ENABLE
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 75497472 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX1" ON "VOIP"."MONTHLY_BILLING_DETAILS" (TRUNC("DATETIME_CONNECT")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX10" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("CALL_TYPE") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX2" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("FROM_EXCHANGE") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX3" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("FROM_FULL_TELEPHONE", TRUNC("DATETIME_CONNECT")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX4" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("DATETIME_CONNECT", NVL("FROM_FULL_TELEPHONE","CALLINGPARTYNUMBER")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 5242880 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX5" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("DATETIME_CONNECT", NVL("TO_FULL_TELEPHONE","ORIGINALCALLEDPARTYNUMBER")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 5242880 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX6" ON "VOIP"."MONTHLY_BILLING_DETAILS" (TO_CHAR("DATETIME_CONNECT",'fmMONTH YYYY')) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX7" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("TO_EXCHANGE") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX8" ON "VOIP"."MONTHLY_BILLING_DETAILS" (NVL("FROM_FULL_TELEPHONE","CALLINGPARTYNUMBER")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX9" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("DATETIME_CONNECT") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    

    These are the functions to determine if a phone number is assigned to multiple staffs or departments:

    FUNCTION GET_EMPLOYEE_NAME (P_FROM_FULL_TELEPHONE IN VARCHAR2)
    RETURN VARCHAR2
    AS
      L_NAME EMPLOYEES.NAME%TYPE;
    BEGIN
      SELECT NAME
      INTO L_NAME
      FROM EMPLOYEES
      WHERE WORK_PHONE_1_FORMAT = P_FROM_FULL_TELEPHONE;
      
      RETURN L_NAME;
    EXCEPTION
      WHEN TOO_MANY_ROWS THEN
        L_NAME := 'Multiple Employees';
        RETURN L_NAME;
      WHEN NO_DATA_FOUND THEN
        L_NAME := 'No Employee Assigned';
        RETURN L_NAME;
      WHEN OTHERS THEN
        NULL;
    END;
    

    FUNCTION GET_DEPARTMENT_NAME (P_FROM_FULL_TELEPHONE IN VARCHAR2)
    RETURN VARCHAR2
    AS
      L_DEPT_DESCR EMPLOYEES.DEPT_DESCR%TYPE;
    BEGIN
      SELECT DEPT_DESCR
      INTO L_DEPT_DESCR
      FROM EMPLOYEES
      WHERE WORK_PHONE_1_FORMAT = P_FROM_FULL_TELEPHONE;
      
      RETURN L_DEPT_DESCR;
    EXCEPTION
      WHEN TOO_MANY_ROWS THEN
        L_DEPT_DESCR := 'Multiple Departments';
        RETURN L_DEPT_DESCR;
      WHEN NO_DATA_FOUND THEN
        L_DEPT_DESCR := 'No Department Assigned';
        RETURN L_DEPT_DESCR;
      WHEN OTHERS THEN
        NULL;
    END;
    

    This is the point of view that I'll use in the report:

    CREATE OR REPLACE FORCE VIEW "VOIP"."TOP_USERS_BY_CALLS_V" ("TOP_NO", "EMPLOYEE_NAME", "EMPLOYEE_DEPARTMENT", "PHONE_NUMBER", "QUANTITY_CALLS") AS 
      SELECT
      ROWNUM,
      VOIP_PKG.GET_EMPLOYEE_NAME(FROM_FULL_TELEPHONE),
      VOIP_PKG.GET_DEPARTMENT_NAME(FROM_FULL_TELEPHONE),
      FROM_FULL_TELEPHONE,
      QUANTITY_CALLS
    FROM (
    SELECT
      MBD.FROM_FULL_TELEPHONE,
      COUNT(1) QUANTITY_CALLS
    FROM
      MONTHLY_BILLING_DETAILS MBD
    WHERE
      MBD.FROM_FULL_TELEPHONE IS NOT NULL                                     AND
      MBD.FROM_FULL_TELEPHONE <> '000-000-0000'                               AND
      LENGTH(MBD.FROM_FULL_TELEPHONE) = 12                                    AND
      LENGTH(MBD.TO_FULL_TELEPHONE) = 12                                      AND
      SUBSTR(MBD.TO_FULL_TELEPHONE,1,3) NOT IN (SELECT AREA_CODE
                                                FROM NYNJ_METRO_AREA_CODES)   AND
      SUBSTR(MBD.TO_FULL_TELEPHONE,1,3) NOT IN ('800','822','833','844',
                                                '855','866','877','888')
    GROUP BY
      MBD.FROM_FULL_TELEPHONE
    ORDER BY
      QUANTITY_CALLS DESC
    )
    WHERE ROWNUM <= 100;
    

    Explain Plan output and Extended SQL Trace:


    SQL> 
    SQL> show parameter user_dump_dest
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    user_dump_dest                       string      D:\ORACLEHOMES\ADMIN\RTS9\UDUM
                                                     P
    SQL> 
    SQL> show parameter optimizer
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      10.2.0.5
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    SQL> 
    SQL> show parameter db_file_multi
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_file_multiblock_read_count        integer     16
    SQL> 
    SQL> show parameter db_block_size
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_block_size                        integer     8192
    SQL> 
    SQL> show parameter cursor_sharing
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    cursor_sharing                       string      EXACT
    SQL> 
    SQL> column sname format a20
    SQL> column pname format a20
    SQL> column pval2 format a20
    SQL> 
    SQL> select
      2  sname
      3  , pname
      4  , pval1
      5  , pval2
      6  from
      7  sys.aux_stats$;
    
    SNAME                PNAME                     PVAL1 PVAL2
    -------------------- -------------------- ---------- --------------------
    SYSSTATS_INFO        STATUS                          COMPLETED
    SYSSTATS_INFO        DSTART                          02-09-2009 15:46
    SYSSTATS_INFO        DSTOP                           02-09-2009 15:46
    SYSSTATS_INFO        FLAGS                         1
    SYSSTATS_MAIN        CPUSPEEDNW            1259.6206
    SYSSTATS_MAIN        IOSEEKTIM                    10
    SYSSTATS_MAIN        IOTFRSPEED                 4096
    SYSSTATS_MAIN        SREADTIM
    SYSSTATS_MAIN        MREADTIM
    SYSSTATS_MAIN        CPUSPEED
    SYSSTATS_MAIN        MBRC
    SYSSTATS_MAIN        MAXTHR
    SYSSTATS_MAIN        SLAVETHR
    
    13 rows selected.
    
    Elapsed: 00:00:00.03
    SQL> 
    SQL> explain plan for
      2  SELECT
      3    TOP_NO,
      4    EMPLOYEE_NAME,
      5    EMPLOYEE_DEPARTMENT,
      6    PHONE_NUMBER,
      7    QUANTITY_CALLS
      8  FROM
      9    TOP_USERS_BY_CALLS_V
     10  ORDER BY
     11    QUANTITY_CALLS DESC;
    
    Explained.
    
    Elapsed: 00:00:00.18
    SQL> 
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 826236322
    
    ----------------------------------------------------------------------------------------------------------------
    | Id  | Operation                          | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                   |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   1 |  SORT ORDER BY                     |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   2 |   VIEW                             | TOP_USERS_BY_CALLS_V      |     1 |  4042 |  1312   (1)| 00:00:16 |
    |*  3 |    COUNT STOPKEY                   |                           |       |       |            |          |
    |   4 |     VIEW                           |                           |     1 |    25 |  1312   (1)| 00:00:16 |
    |*  5 |      SORT ORDER BY STOPKEY         |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |   6 |       HASH GROUP BY                |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |*  7 |        FILTER                      |                           |       |       |            |          |
    |*  8 |         TABLE ACCESS BY INDEX ROWID| MONTHLY_BILLING_DETAILS   |     1 |    26 |  1310   (1)| 00:00:16 |
    |*  9 |          INDEX FULL SCAN           | MONTHLY_BILL_INDEX3       |   934 |       |   449   (1)| 00:00:06 |
    |* 10 |         INDEX FULL SCAN            | NYNJ_METRO_AREA_CODES_UK1 |     1 |     4 |     1   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter(ROWNUM<=100)
       5 - filter(ROWNUM<=100)
       7 - filter( NOT EXISTS (SELECT 0 FROM VOIP."NYNJ_METRO_AREA_CODES" "NYNJ_METRO_AREA_CODES" WHERE
                  LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3))))
       8 - filter(LENGTH("MBD"."TO_FULL_TELEPHONE")=12 AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'800' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'822' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'833' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'844' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'855' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'866' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'877' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'888')
       9 - filter(LENGTH("MBD"."FROM_FULL_TELEPHONE")=12 AND "MBD"."FROM_FULL_TELEPHONE"<>'000-000-0000'
                  AND "MBD"."FROM_FULL_TELEPHONE" IS NOT NULL)
      10 - filter(LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3)))
    
    33 rows selected.
    
    Elapsed: 00:00:00.82
    SQL> 
    SQL> rollback;
    
    Rollback complete.
    
    Elapsed: 00:00:00.00
    SQL> 
    SQL> set autotrace traceonly arraysize 100
    SQL> 
    SQL> alter session set tracefile_identifier = 'mytrace1';
    
    Session altered.
    
    Elapsed: 00:00:00.01
    SQL> 
    SQL> alter session set events '10046 trace name context forever, level 8';
    
    Session altered.
    
    Elapsed: 00:00:00.15
    SQL> 
    SQL> SELECT
      2    TOP_NO,
      3    EMPLOYEE_NAME,
      4    EMPLOYEE_DEPARTMENT,
      5    PHONE_NUMBER,
      6    QUANTITY_CALLS
      7  FROM
      8    TOP_USERS_BY_CALLS_V
      9  ORDER BY
     10    QUANTITY_CALLS DESC;
    
    100 rows selected.
    
    Elapsed: 00:10:37.68
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 826236322
    
    ----------------------------------------------------------------------------------------------------------------
    | Id  | Operation                          | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                   |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   1 |  SORT ORDER BY                     |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   2 |   VIEW                             | TOP_USERS_BY_CALLS_V      |     1 |  4042 |  1312   (1)| 00:00:16 |
    |*  3 |    COUNT STOPKEY                   |                           |       |       |            |          |
    |   4 |     VIEW                           |                           |     1 |    25 |  1312   (1)| 00:00:16 |
    |*  5 |      SORT ORDER BY STOPKEY         |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |   6 |       HASH GROUP BY                |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |*  7 |        FILTER                      |                           |       |       |            |          |
    |*  8 |         TABLE ACCESS BY INDEX ROWID| MONTHLY_BILLING_DETAILS   |     1 |    26 |  1310   (1)| 00:00:16 |
    |*  9 |          INDEX FULL SCAN           | MONTHLY_BILL_INDEX3       |   934 |       |   449   (1)| 00:00:06 |
    |* 10 |         INDEX FULL SCAN            | NYNJ_METRO_AREA_CODES_UK1 |     1 |     4 |     1   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter(ROWNUM<=100)
       5 - filter(ROWNUM<=100)
       7 - filter( NOT EXISTS (SELECT 0 FROM VOIP."NYNJ_METRO_AREA_CODES" "NYNJ_METRO_AREA_CODES" WHERE
                  LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3))))
       8 - filter(LENGTH("MBD"."TO_FULL_TELEPHONE")=12 AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'800' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'822' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'833' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'844' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'855' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'866' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'877' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'888')
       9 - filter(LENGTH("MBD"."FROM_FULL_TELEPHONE")=12 AND "MBD"."FROM_FULL_TELEPHONE"<>'000-000-0000'
                  AND "MBD"."FROM_FULL_TELEPHONE" IS NOT NULL)
      10 - filter(LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3)))
    
    
    Statistics
    ----------------------------------------------------------
            365  recursive calls
              0  db block gets
         689543  consistent gets
         212906  physical reads
              0  redo size
           5984  bytes sent via SQL*Net to client
            400  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              2  sorts (memory)
              0  sorts (disk)
            100  rows processed
    
    SQL> 
    SQL> disconnect
    

    Part of the automatic trace output:

    SELECT
      TOP_NO,
      EMPLOYEE_NAME,
      EMPLOYEE_DEPARTMENT,
      PHONE_NUMBER,
      QUANTITY_CALLS
    FROM
      TOP_USERS_BY_CALLS_V
    ORDER BY
      QUANTITY_CALLS DESC
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.43          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2     24.70     635.81     212587     631823          0         100
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4     24.70     636.25     212587     631823          0         100
    
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 148  
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
        100  SORT ORDER BY (cr=689531 pr=212900 pw=0 time=636823070 us)
        100   VIEW  TOP_USERS_BY_CALLS_V (cr=689531 pr=212900 pw=0 time=642681672 us)
        100    COUNT STOPKEY (cr=631823 pr=212587 pw=0 time=635667026 us)
        100     VIEW  (cr=631823 pr=212587 pw=0 time=635666810 us)
        100      SORT ORDER BY STOPKEY (cr=631823 pr=212587 pw=0 time=635666493 us)
       2512       HASH GROUP BY (cr=631823 pr=212587 pw=0 time=635666125 us)
      27112        FILTER  (cr=631823 pr=212587 pw=0 time=519230237 us)
     315563         TABLE ACCESS BY INDEX ROWID MONTHLY_BILLING_DETAILS (cr=381523 pr=212587 pw=0 time=580209555 us)
     394473          INDEX FULL SCAN MONTHLY_BILL_INDEX3 (cr=2679 pr=2679 pw=0 time=26793918 us)(object id 206675)
     226627         INDEX FULL SCAN NYNJ_METRO_AREA_CODES_UK1 (cr=250300 pr=0 pw=0 time=3575488 us)(object id 206605)
    
    
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      db file sequential read                    212587        0.20        611.67
      SQL*Net message from client                     2        0.00          0.00
      SQL*Net more data to client                     2        0.00          0.00
    ********************************************************************************
    

    DBMS_XPLAN. Output DISPLAY_CURSOR:

    SQL> 
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    SQL_ID  1ut636vt58jdw, child number 0
    -------------------------------------
    SELECT /*+ gather_plan_statistics */   TOP_NO,   EMPLOYEE_NAME,   EMPLOYEE_DEPARTMENT,   PHONE_NUMBER,   QUANTITY_CALLS FROM   TOP_USERS_BY_CALLS_V
    ORDER BY   QUANTITY_CALLS DESC
    
    Plan hash value: 826236322
    
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                          | Name                      | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |  OMem |  1Mem | Used-Mem |
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                   |                           |      1 |        |    100 |00:09:56.06 |     689K|    210K|       |       |          |
    |   1 |  SORT ORDER BY                     |                           |      1 |      1 |    100 |00:09:56.06 |     689K|    210K| 13312 | 13312 |12288  (0)|
    |   2 |   VIEW                             | TOP_USERS_BY_CALLS_V      |      1 |      1 |    100 |00:10:04.98 |     689K|    210K|       |       |          |
    |*  3 |    COUNT STOPKEY                   |                           |      1 |        |    100 |00:09:54.89 |     631K|    210K|       |       |          |
    |   4 |     VIEW                           |                           |      1 |      1 |    100 |00:09:54.89 |     631K|    210K|       |       |          |
    |*  5 |      SORT ORDER BY STOPKEY         |                           |      1 |      1 |    100 |00:09:54.88 |     631K|    210K|  6144 |  6144 | 6144  (0)|
    |   6 |       HASH GROUP BY                |                           |      1 |      1 |   2512 |00:09:54.88 |     631K|    210K|   821K|   821K| 1153K (0)|
    |*  7 |        FILTER                      |                           |      1 |        |  27112 |00:08:58.57 |     631K|    210K|       |       |          |
    |*  8 |         TABLE ACCESS BY INDEX ROWID| MONTHLY_BILLING_DETAILS   |      1 |      1 |    315K|00:08:57.07 |     381K|    210K|       |       |          |
    |*  9 |          INDEX FULL SCAN           | MONTHLY_BILL_INDEX3       |      1 |    934 |    394K|00:00:23.02 |    2679 |   2679 |       |       |          |
    |* 10 |         INDEX FULL SCAN            | NYNJ_METRO_AREA_CODES_UK1 |    250K|      1 |    226K|00:00:03.47 |     250K|      0 |       |       |          |
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter(ROWNUM<=100)
       5 - filter(ROWNUM<=100)
       7 - filter( IS NULL)
       8 - filter((LENGTH("MBD"."TO_FULL_TELEPHONE")=12 AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'800' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'822'
                  AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'833' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'844' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'855'
                  AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'866' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'877' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'888'))
       9 - filter((LENGTH("MBD"."FROM_FULL_TELEPHONE")=12 AND "MBD"."FROM_FULL_TELEPHONE"<>'000-000-0000' AND "MBD"."FROM_FULL_TELEPHONE" IS NOT NULL))
      10 - filter(LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3)))
    
    
    35 rows selected.
    
    Elapsed: 00:00:00.50
    SQL> 
    SQL> spool off
    
    

    Any help will be greatly appreciated. Please let me know if you need additional information.

    Thank you

    Erick

    ediazjorge wrote:

    Please let me know if you need additional information or do additional tests.

    Thanks again!

    Erick

    It's to you if you are satisfied or interested in improvements (if possible).

    If so the first thing I would like if you had your refreshed perspective as advised. According to expected area_code table cardinalities I doubt.

    So, if not cool off with dbms_stats.gather_table_stats on two tables, area_codes and MONTHLY_BILLING_DETAILS.

    Bottlenecks are now obviously the full table of MONTHLY_BILLING_DETAILS as well as the ANTI of LOOPS IMBRIQUEES scan.

    At the moment I don't think that an index of MONTHLY_BILLING_DETAILS will help a lot, because most of the lines will pass filter predicates, and because we need some columns in it, I have now I there will be gain a full index scan.

    I was surprissed that the optimizer pushes the substr <> predicates to both tables.

    So depending on your data, you might try

    1 make a factory of subquery select the two MONTHLY_BILLING_DETAILS columns that all directly apply predicates of membership and use it directly in the join instead of the table.

    or

    2. If all subtr to so are part of the table area_code choose in it using a subquery (or inline view) plant excluding these values.

    Both are attempts to get rid of the substr excluding as filters of join predicates.

    In fact, I was expecting a hash join anti as shown in the plan to explain instead of the nested loops anti, I expect to be more effective in this case.

    Perhaps with correct cardinalities the optimizier would understand himself.

    Just to test it, you can try the use_hash hint in the join:

    Select / * + USE_HASH (MBD, one) * /.

    ..

    OF MONTHLY_BILLING_DETAILS MBD,.

    NYNJ_METRO_AREA_CODES one

    (It's a good habit anyway usually use aliases and precede the names of columns. In the, it is easier to read queries are only trivial).

  • Need help with script to remove audit ASM files

    Hello

    It would be great if someone can provide me with a script to delete the files of audit and trace on ASM files

    Thank you

    Aerts.

    Ed,

    I have a shell script which is run via cron once a week.  Of course, you need to change the location of the trace and audit files.  This script will remove all files .trc and .trm more than 10 days

    #! / bin/bash

    find/u01/app/oracle/diag/rdbms /... dbname... / path-name ' * .trc ' - mtime + 10 - type f-exec rm '{} ';

    find/u01/app/oracle/diag/rdbms /... dbname... / path-name ' * .trm ' - mtime + 10 - type f-exec rm '{} ';

  • I can control the Trace files in bdump

    Experts in good morning...

    Question of BDUMP

    In BDUMP, I have the following files...

    -rw - r - 1 oracle oinstall 112687 19 Feb 13:41 alert_testdb.log
    -rw - r - r - 1 oracle oinstall 33068 Feb 19 12:03 alert_TSH1.log
    -rw - r - 1 oracle oinstall 20301 14 Feb 09:13 testdb_arc0_15379.trc
    -rw - r - 1 oracle oinstall 632 5 Feb 04:56 testdb_arc0_17339.trc
    -rw - r - 1 oracle oinstall 2118 Feb 5 05:22 testdb_arc0_17409.trc
    ... ..
    .... ..

    Totally 294 trace files...


    I checked some .trc files;  Almost have the same information.

    ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1
    Name of the system: Linux
    Name of the node: xxxxxxxxxxxxxx
    News Release: xxxxxxxxxxxxxxxxxxxxxxxxxx
    Version: xxxxxxxxxxxxxxxxxxxxxxxxx
    Machine: xxxxxx
    Instance name: testdb
    Redo thread mounted by this instance: 1
    Oracle process number: 0

    My question clear is:

    1. If the alert log contains details of the error, what is the purpose of trace in bdump files?
    2. why "n" no trace files created without useful information? (Almost with the same information]
    3. what type of information is usually stored in .trc files?

    What I know about tracefiles:

    Each background process writes the trace files if an internal error has occurred.
    If I'm wrong, please correct.

    Trace files and log alerts serve a different purpose. A simple way to think about it, is that the trace files are used when diagnosing problems. The alert log shows you what are the events are occurring in the database in general, flooding you don't not with unnecessary details. If the database crashed, the alerts log will tell you when the event happened, but the details of the process that crashed would be (I hope) in a trace file.

    Some trace files are huge, and you certainly don't want them in the log of alerts because it would make it too big to be manageable or read.

    For example, if a process crashes, the dumping process trace file to would be useful when you are working with Oracle Support to identify the problem. Or, if you want to see what a specific session, you can turn on tracing on it and and then format the trace with tkprof file to understand what made the session.

    The documentation is a good summary:

    Trace files

    A trace file is an administrative file containing diagnostic data used to investigate the problems. Trace can also, provide guidance for tuning applications or an instance, as explained in "Diagnostic and performance optimization.

    Types of Trace files

    Each server and the background process can periodically write to a trace file. File information on the environment in the process, status, activities and errors.

    The SQL trace facility also created trace files, which provide information of performance on individual SQL statements. To enable tracing for an identifier of the client, service, module, action, session, instance or database, you must run the procedures in the DBMS_MONITOR package or use Oracle Enterprise Manager.

    A dump is a special type of trace file. Considering that track tends to be out of diagnostic data, a dump is usually a unique data output of diagnosis in response to an event (for example, an incident). When an incident occurs, the database writes one or more landfills in the incident directory created for the incident. Incident of discharges also contain the case number in the file name.

  • How do I get all the SQL executed by my session?

    How do I get all the SQL executed by my session?

    Published by: user11300376 on 01/28/2013 11:27

    user11300376 wrote:
    I had tried, brings itself however only select table v $ session.

    Executed orders:

    SELECT * FROM MBS_ITEM;

    SELECT b.sql_id, b.sql_text
    SESSION $ v a, v$ sql b
    WHERE a.sql_id = b.sql_id;

    The output result:

    SQL_ID SQL_TEXT
    1 4qg3bft0w37rt SELECT b.sql_id, b.sql_text FROM session $ v a, v$ sql b WHERE a.sql_id = b.sql_

    The listed application is good, but does not limit the output of your session - it should return data from all sessions.

    You must add an AND condition in the WHERE clause to limit your session. You can try this (untested)

     where audsid=(select userenv('sessionid') from dual);
    

    You can also perform a SQL trace and tkprof to obtain data to SQL executed the trace start and end of the trace.

Maybe you are looking for

  • Replace the HARD drive in mid-2012 MBP of SSD?

    Given to replace my HARD drive of 1 TB in MBP mid-2012.  This MBP has already been customized (by Apple) to 2.9 GHz i7 8 GB mem. I'm looking for a solution at least to 1 TB also. How about this: Samsung 850 EVO 1 TB 2.5 inch SATA III internal SSD (MZ

  • My profile is missing for Firefox does not open. How can I reset it then?

    I've been using Firefox since one some time walking, but used a different browser as my main. Now that this browser is obsolete and there is no update available, I wanted to switch to Firefox permanently. Given that all my favorites are only updated

  • How remove adware 'alwaysnewsoft' point 'traffic-portal' point 'net '?

    I accidentally contaminated my Mac Pro with the 'alwaysnewsoft' dot "traffic-portal" dot "net" adware/malware, which prevents me from using Safari, unless I click OK on a warning that I am not ready to touch. Does anyone know how to remove it? Googli

  • HP 14-g003au: Bluetooth does not

    I can not useBluetooth... Please tell me how to fix it Sir... Bluetooth also here but this icon works don't no how I can fix it help me please

  • BlackBerry Smartphones can't find my contacts.

    I'm new to Blackberry and I have Verizon.  My list of contacts from my old phone was transferred with the program Back Up Assistant to my BB.  My problem is that I can't get to the top of the list.  I know that it is there, because when I dial a numb