# Query plan is different in master and slave

**URL:** <https://forums.percona.com/t/query-plan-is-different-in-master-and-slave/4339>\
**Category:** Other MySQL® Questions\
**Created:** [August 11, 2015, 7:09am UTC](https://forums.percona.com/t/query-plan-is-different-in-master-and-slave/4339 "2015-08-11T07:09:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ikonrao](https://avatars.discourse-cdn.com/v4/letter/i/a9adbd/32.png) [@ikonrao](https://forums.percona.com/u/ikonrao)\
**Post date:** [August 11, 2015, 7:09am UTC](https://forums.percona.com/t/query-plan-is-different-in-master-and-slave/4339/1 "2015-08-11T07:09:53Z")

</div>

Hello,

I was working on query optimization, during which I found that query plan on master and slave is different. Mysql version is same on both the servers. On Master it takes around 6 seconds to execute whereas in slave it takes around 1 second.

Only difference is query plan, rest all is same.

mysql version: 5.6.21

---

<div class="post-metadata">

**Author:** ![scott.nemes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/scott.nemes/32/5_2.png) [@scott.nemes](https://forums.percona.com/u/scott.nemes)\
**Post date:** [August 11, 2015, 8:31pm UTC](https://forums.percona.com/t/query-plan-is-different-in-master-and-slave/4339/2 "2015-08-11T20:31:24Z")

</div>

Hi ikonrao;

I would try running analyze table on both the master and slave and see if it matches after that. You could also rebuild the table with pt-online-schema-change for an “online” variation.

-Scott
