Skip to Main Content
  • Questions
  • Different Execution Plan across RAC node

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question.

Asked: December 01, 2014 - 8:51 am UTC

Last updated: October 16, 2018 - 2:15 am UTC

Version: 10.2.0.4.0

Viewed 10K+ times! This question is

You Asked

1. is it possible to have different execution plan across RAC nodes for the same Query ?
2. let's say if i run a query on Node 1 and generated a execution plan named "node1Query1" , will it share between different node ? or it will have another one if i run it again on Node 2?

looking forward for your reply.


and Tom said...

1) absolutely, by design. In fact - you can have more than one execution plan for the same query in a single instance - you don't even need RAC.

2) each node will hard parse its query. due to things like bind peeking, having different optimizer settings on each node and so on - you can easily end up with a different plan on the two nodes. definitely

Rating

  (5 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Same optimizer setting in all RAC nodes

Rajeshwaran, Jeyabal, December 03, 2014 - 2:49 pm UTC

Tom:

lets say all nodes in RAC have same optimizer settings.

and the node#1 Hard-parses this query
select * from t where primary_key = ?
then this will be available in library cache of node#1

when the same query is executed from node#2 - will that get shared from node#1 or does it hardparsed again in node#2 ?
Tom Kyte
December 03, 2014 - 3:38 pm UTC

it hard parses it, each instance will always hard parse it the first time at least...

and each could get a different plan, probably not for that query - but it could!

A reader, December 03, 2014 - 6:16 pm UTC

considering same hardware (i.e. CPU/memory) for each node and same optimizer setting for each node even than we could have different plan for same query?

if yes than what will be the reason. can you please explain?

Tom Kyte
December 03, 2014 - 7:50 pm UTC

bind peeking is the very first thing that pops into my mind.

https://www.google.com/search?q=site%3Atkyte.blogspot.com+"bind+peeking"

absolutely.

Even within a *single* node there can be more than one plan for a single query - easily. Happens all of the time.

Execute Gather Stats on each node

A reader, January 16, 2017 - 3:58 pm UTC

Hi,

So does this mean if i am running exec gather_stats to improve the performance of my database after some of the tables have crossed 50 million rows, i need to run it on every node in the RAC separately. Will it not be sufficient to run it on just one node.

Thanks in advance,
Cheers,
Vipin.
Chris Saxon
January 16, 2017 - 5:52 pm UTC

The stats are the same across all the nodes in the cluster. So no.

Krishnaprasad Yadav, May 01, 2018 - 12:50 pm UTC

Hi Team,

I have faced this problem recently in 2 node rac system , in both node for one of sql id plan hash value was different ,
i purged bad plan from one of node but unfortunately it still picked up old plan .

How to get rid of this bad plan . additionally how bind peeking can cause change of different plan in in RAC ?
Connor McDonald
May 02, 2018 - 1:56 am UTC

Best way to lock in a particular plan is with SQL Plan Management

http://www.oracle.com/technetwork/database/bi-datawarehousing/twp-sql-plan-management-11gr2-133099.pdf

Do we need to pin the plan all nodes?

Saad Ahmad, October 14, 2018 - 10:52 pm UTC

do we need to run the PL/SQl to pin the plan explicitly on all nodes or running on ANY node with an input of sql_id and plan_id enough?
Connor McDonald
October 16, 2018 - 2:15 am UTC

Single node should suffice because the sql plan management details are stored in the data dictionary, which is common to all nodes.

More to Explore

Performance

Get all the information about database performance in the Database Performance guide.