1

We've just moved our db server onto a new machine and upgraded to mysql 5.6 from 5.0. we have a bailout server that is kept in sync and is still at mysql 5.0, all tables are MyISAM, and I'm hitting slowdown on the new server. I've run Check, Analyze, Repair, Optimize on all relevant tables, on both servers, and still the new server takes approx 20 seconds against the old server's 0.2 seconds to run the following query.

SELECT DISTINCT `personBaseData`.`PersonID`, 
            `personBaseData`.`Forename`, 
            `personBaseData`.`Nickname`, 
            `personBaseData`.`Surname`, 
            COUNT(*) AS Count 
FROM   `personBaseData` 
   LEFT JOIN `sessionAttendance` 
          ON (( `personBaseData`.`PersonID` = 
                 `sessionAttendance`.`ContactID` ) 
               AND ( `sessionAttendance`.`ContactType` = 'Individual' ) ) 
   JOIN `sessionBaseData` 
          ON (( `sessionAttendance`.`SessionID` = `sessionBaseData`.`SessionID` )) 
   JOIN `sessionGroupBaseData` 
          ON (( `sessionBaseData`.`SessionGroupID` = `sessionGroupBaseData`.`SessionGroupID` )) 
WHERE  `personBaseData`.`PersonID` IN (SELECT `PersonID` 
                                   FROM   `personFlexData` 
                                   WHERE  ( `flexName` = 'Organisation_P_27' 
                                            AND `flexValue` = 'HCCT' )) 
   AND `sessionBaseData`.`StartDate` > '2013-08-15' 
   AND `sessionAttendance`.`Attended` = '1' 
   AND `sessionGroupBaseData`.`Title` = 'Open Access (HCCT)' 
   AND `personBaseData`.`Type` & '1' 
GROUP  BY `personBaseData`.`PersonID` 
ORDER  BY Count DESC, 
      `personBaseData`.`Forename` ASC, 
      `personBaseData`.`Nickname` ASC, 
      `personBaseData`.`Surname` ASC ;

Running explain on this sql on both servers, come back with

New 5.6 Server

enter image description here

Bailout 5.0 Server

enter image description here

Is there anything obvious I can pursue, looks like a walk through the variables, and looking for anything obvious, but I'm not exactly sure what the main kickers might be, but clearly I'd like to be doing Primary selects not Simple ones, and only having one large row count.

Thanks in advance

Cliffordlife
  • 488
  • 5
  • 13

2 Answers2

2

During the release/review process to 5.5 we examined every setting in 5.0 vs 5.5 vs 5.6, to try and create a super set.

We identified a large change in the optimizer_switch setting in 5.5 to 5.6, so though before we roll back let's set the extras to off.

This worked.

On further inspection, the critical setting was semijoin. Setting this to off, made 5.6 as quick as 5.5

I really hope this helps someone.
Cheers

Cliffordlife
  • 488
  • 5
  • 13
1

Ok so it appears that 5.5 runs the queries as quickly as 5.0, so we've rolled back to 5.5
Quite a complex issue, here are the resources I found to be helpful.

Same issue as us possibly
Slow query after upgrade mysql from 5.5 to 5.6

replace joins with STRAIGHT_JOIN everywhere?
Percona 5.6 InnoDB issue not using indexes correctly

Suggests 5.6 is better than 5.5
MySQL long running query in 5.5 is very fast in 5.6

More about straight joins
When to use STRAIGHT_JOIN with MySQL

More 5.6 configuration advice from the floor
https://www.facebook.com/notes/mysql-at-facebook/my-mysql-is-faster-than-your-mysql/10151250402570933
http://dev.mysql.com/doc/refman/5.6/en/performance-schema-configuration.html http://www.percona.com/live/mysql-conference-2013/sites/default/files/slides/mysql-56-experiences-bugs-solutions-50mins.pdf

Turn off MRR

probably worth reading the optimizer parts of this page
http://dev.mysql.com/doc/refman/5.6/en/mysql-nutshell.html
and all point releases back to 5.0

http://www.mysqlperformanceblog.com/2013/02/18/is-mysql-5-6-slower-than-mysql-5-5/

http://dev.mysql.com/doc/refman/5.5/en/upgrading.html

Wow
http://mysqlentomologist.blogspot.co.uk/2013/06/fun-with-bugs-11-top-10-optimizer.html

Cheers

Community
  • 1
  • 1
Cliffordlife
  • 488
  • 5
  • 13