Skip navigation links

MySQL Forums :: Optimizer & Parser :: Identical servers different plan for the same query


Advanced Search

Re: Identical servers different plan for the same query
Posted by: Rick James ()
Date: April 08, 2012 12:20PM

> Shouldn't both servers use the same query plan?
I have seen as many as 6 different query plans for similar queries, differing only in the constants used. Even with identical constants, the query plan can vary even on the same machine.

InnoDB does 8 random dives into the indexes when the table is first opened, and at certain other times. From this it deduces the statistics which it uses to decide on the 'best' plan.

The Master and Slave do not necessarily have all the rows in exactly the same blocks. This does not impact the results of identical queries, but could impact the statistics.

ANALYZE TABLE is one of the things that will cause InnoDB to recompute the statistics -- for better or worse.

UNIQUE (`timestamp`,`zone`,`pool_type_id`,`week`,`account`,`instance_class`,`operation`)
Beware -- we are likely to jump on how awful that index looks.

on pu.region = lt.region and
pu.timestamp = lt.timestamp and
sounds unsafe -- unless you are absolutely sure no two things can happen at exactly the same second.

Options: ReplyQuote


Subject Views Written By Posted
Identical servers different plan for the same query 1583 Eric Coll 04/07/2012 01:20AM
Re: Identical servers different plan for the same query 675 Eric Coll 04/07/2012 09:55AM
Re: Identical servers different plan for the same query 674 irek kordirko 04/07/2012 02:54PM
Re: Identical servers different plan for the same query 882 Rick James 04/08/2012 12:20PM
Re: Identical servers different plan for the same query 902 Eric Coll 04/09/2012 10:24AM
Re: Identical servers different plan for the same query 625 Eric Coll 04/09/2012 10:35AM
Re: Identical servers different plan for the same query 638 Eric Coll 04/09/2012 10:37AM
Re: Identical servers different plan for the same query 618 Eric Coll 04/09/2012 10:42AM
Re: Identical servers different plan for the same query 610 Eric Coll 04/10/2012 03:28PM
Re: Identical servers different plan for the same query 653 Rick James 04/10/2012 10:29PM
Re: Identical servers different plan for the same query 642 Eric Coll 04/11/2012 10:05AM
Re: Identical servers different plan for the same query 676 Rick James 04/12/2012 08:56AM
Re: Identical servers different plan for the same query 642 Eric Coll 04/12/2012 03:23PM
Re: Identical servers different plan for the same query 673 Rick James 04/13/2012 03:49PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.