Can you please tell how can we improve performance of an SQL query?
Can you please tell how can we improve performance of an SQL query?
More effective measure of performance tuning results is response time. There are many factors which effect the performance of a SQL query. Identify the most common SQL statements, tune each one by carefully reviewing the execution plan for the SQL and adjust the execution plan using Oracle hints.
You can improve sql statement efficiency by following steps :
1.Verifying optimizer statisticsverifying optimizer statistics
2.Reviewing the execution plan 3.restructuring the sql statements
4.Creating indexes and restructuring the indexes
5.Modifying or disabling triggers and constraints
6.Restructuring the data
7.Maintaining execution plans over time
8.Visiting data as few times as possible etc.
There is no single way to tune the sql query. no one can help you about it beacause it tunning depends on the execution the sql.
I suggest you that by using the explain plan check the execution of query and go well to it.
and also check the sga parameter.
Whenever you read or write data in Oracle, you do so by issuing an SQL statement. One of Oracle's task when it receives such a statement is to build a query execution plan. An execution plan defines how Oracle finds or writes the data. For example, an important decision that Oracle has to take is if it uses indexes or not. And if there are more indexes, which of these is used. All this is contained in an execution plan. If one wants to explore such an execution plan, Oracle provides the SQL statement EXPLAIN PLAN to determine this. The general syntax of EXPLAIN PLAN is:
explain plan for your-precious-sql-statement;
For detail information about explain plan refer this link
If you use sqldeveloper of oracle, you can just click on a button and see the explain plan as well as a the trace. The trace is also useful in tuning the queries.
Of course there are things beyond sql too that need more tweaking, e.g. the pga_agrregate_target that plays an important role in sorting.