Thread: same explain plan but different response time between two days
Started 1 month, 3 weeks ago by Mohamed Houri
Two days ago, I run a query which was performing very badly (33 records returned in more than 18 minutes). I then have generated its corresponding explain plan and started looking how to improve it. Finally, when I have changed a little bit the order by clause, the query performed very well.
Today, I was going to implement this change of order by clause in...
I think you have answered your own question :- "The only differences are in the numbers of rows, bytes, costs and a new column named TempSpc has been added into the new explain plan."
Do all tables and indexes have stats ?
Did the two statements use the same bind variables, or different ? E.g
select count(*) from employee where gender = &input1;...
And now at 10h30 it is again performing badly with exactly the same explain plan as the one corresponding to this morning very performant query!!!
Mohamed Houri
Yes the two statements use the same bind variables.
This morning I run the query and it tooks less than 1 seconde to complete. I have just go the time to post my thread and now the same query with the same bind variables are runing very slowly (about 5 minutes to complete).
The explain plans of the two statements are now exactly the same.
Regards
...
Mohamed Houri wrote:
Yes the two statements use the same bind variables.
This morning I run the query and it tooks less than 1 seconde to complete. I have just go the time to post my thread and now the same query with the same bind variables are runing very slowly (about 5 minutes to complete).
The explain plans of the two statements are now exactly...
Thanks Charles,
I am using Release 10.2.0.4.0
I am using explain plan for (query goes here.....) and select * from table(dbms_xplan.display) to get the explain plan.
Actually the query is runing fast. I will trace it with 10046 level 12 when it will performs badly
Regards
Mohamed
Oracle's bind variable peeking may be at play, here.
Have a Google for it - there's good stuff on Jonathan Lewis' site about it.
An example: the first query to run one day uses search value "USA" for a query - later, "DCG" is used as the search value.
The first query is a lucky one: it leads to an index being used, as "USA" appears very infrequently ...
The EXPLAIN PLAN FOR ... syntax may also display inaccurate execution plans. Bind variable peeking does not take place with EXPLAIN PLANs, while it does take place during a normal query parse and execute in 9i and above. Additionally, you could find that all bind variables are treated as VARCHAR2 in an EXPLAIN PLAN. If I recall correctly, EXPLAIN PLAN FOR ...
Mohamed Houri wrote:
Yes the two statements use the same bind variables.
This morning I run the query and it tooks less than 1 seconde to complete. I have just go the time to post my thread and now the same query with the same bind variables are runing very slowly (about 5 minutes to complete).
The explain plans of the two statements are now exactly...
Hi all,
I prefer to retreive the execution plan with execution stats. Thus you will be able to compare the estimated rows with the number of rows really processed.
ex:
SELECT * FROM table(dbms_xplan.display_cursor(NULL,NULL,'iostats last'));
But you have to add the hint /*+ gather_plan_statistics */ into the sql statement or to set the TIMED_...
Thanks Charles, I am using Release 10.2.0.4.0 I am using explain plan for (query goes here.....) and select * from table(dbms_xplan.display) to get the explain plan. Actually the query is runing fast. I will trace it with 10046 level 12 when it will performs badly Regards Mohamed
The EXPLAIN PLAN FOR ... syntax may also display inaccurate execution plans. Bind variable peeking does not take place with EXPLAIN PLANs, while it does take place during a normal query parse and execute in 9i and above. Additionally, you could find that all bind variables are treated as VARCHAR2 in an EXPLAIN PLAN. If I recall correctly, EXPLAIN PLAN FOR should (could?) trigger a hard parse of the SQL statement rather than reusing the...
Oracle's bind variable peeking may be at play, here. Have a Google for it - there's good stuff on Jonathan Lewis' site about it. An example: the first query to run one day uses search value "USA" for a query - later, "DCG" is used as the search value. The first query is a lucky one: it leads to an index being used, as "USA" appears very infrequently in the table being queried, and a good plan is...
I think you have answered your own question :- "The only differences are in the numbers of rows, bytes, costs and a new column named TempSpc has been added into the new explain plan." Do all tables and indexes have stats ? Did the two statements use the same bind variables, or different ? E.g select count(*) from employee where gender = &input1; The explain plan may be the same for MALE and FEMALE, but the row counts may be very...
Hi all, I prefer to retreive the execution plan with execution stats. Thus you will be able to compare the estimated rows with the number of rows really processed. ex: SELECT * FROM table(dbms_xplan.display_cursor(NULL,NULL,'iostats last')); But you have to add the hint /*+ gather_plan_statistics */ into the sql statement or to set the TIMED_STATISTICS parameter to ALL.
Mohamed Houri wrote: Yes the two statements use the same bind variables. This morning I run the query and it tooks less than 1 seconde to complete. I have just go the time to post my thread and now the same query with the same bind variables are runing very slowly (about 5 minutes to complete). The explain plans of the two statements are now exactly the same. Charles, and others, have pointed out the problems of using "explain plan"...
Trying to explain the difference between burgandy and... Trying to explain the difference between burgandy and purple to your bf is like trying to explain the difference between a cups and b cups 6:46 PM Nov 29th, 2008 from txt
Thread profile page for "same explain plan but different response time between two days" on http://www.oracle.com.
This report page is a snippet summary view from a single thread "same explain plan but different response time between two days", located on the Message Board at http://www.oracle.com.
This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity