Thursday, May 1, 2025

How to use auto trace for performance tuning ?

 Autotrace 




SQL> set autotrace traceonly explain ;

SQL> set serveroutput on

SQL>

SQL>

SQL> select * from test;


Execution Plan

----------------------------------------------------------

Plan hash value: 1357081020


--------------------------------------------------------------------------

| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |

--------------------------------------------------------------------------

|   0 | SELECT STATEMENT  |      |     6 |   240 |     2   (0)| 00:00:01 |

|   1 |  TABLE ACCESS FULL| TEST |     6 |   240 |     2   (0)| 00:00:01 |

--------------------------------------------------------------------------


Note

-----

   - dynamic statistics used: dynamic sampling (level=2)


SQL> set autotrace off

SQL>





SQL>

SQL>

SQL> set autotrace on

SQL>

SQL> select * from test;


        ID NAME

---------- --------------------------------------------------

         1 A

         1 A

         1 A

         1 A

         1 A

         1 A


6 rows selected.



Execution Plan

----------------------------------------------------------

Plan hash value: 1357081020


--------------------------------------------------------------------------

| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |

--------------------------------------------------------------------------

|   0 | SELECT STATEMENT  |      |     6 |   240 |     2   (0)| 00:00:01 |

|   1 |  TABLE ACCESS FULL| TEST |     6 |   240 |     2   (0)| 00:00:01 |

--------------------------------------------------------------------------


Note

-----

   - dynamic statistics used: dynamic sampling (level=2)



Statistics

----------------------------------------------------------

          0  recursive calls

          0  db block gets

          4  consistent gets

          0  physical reads

          0  redo size

        724  bytes sent via SQL*Net to client

        380  bytes received via SQL*Net from client

          2  SQL*Net roundtrips to/from client

          0  sorts (memory)

          0  sorts (disk)

          6  rows processed


SQL>

SQL> set autotrace off

No comments:

Post a Comment

About the Author : Anurag Pandey | Database cloud Architect | Oracle | SQL Server | PostgreSQL | AI and Data Platform Enthusiast

Anurag Pandey is a Database Architect with expertise in Oracle, PostgreSQL, SQL Server, Linux, and enterprise database platforms and specializes in database architecture, performance tuning, high availability, disaster recovery, cloud modernization, and operational excellence. With extensive experience in enterprise-scale environments, Anurag is passionate about leveraging AI, automation, and modern data platforms to improve reliability, scalability, and business outcomes. He actively contributes to technical communities through knowledge sharing, architecture guidance, and thought leadership in database and data engineering domains.

Follow more articles at

Visit Blog

Oracle 19c to PostgreSQL 15 Migration: Step-by-Step Production Guide (Ora2Pg + DMS)

Production-oriented migration approach for a complex Oracle 19c to PostgreSQL 15 workload , covering assessment, schema and code conversion,...