Thursday, 8 November 2018

MySQL to MariaDB - slow performance

so I have a problem with DB migration from one webserver to another. Server 1 has MySQL version 5.6 running under cPanel hosting... Server 2 has MariaDB version 5.5 running under Webmin/Virtualmin PHP version is the same on both of them...5.6

Anyway, I wanted to move a site from Server 1 to 2. I exported the DB using HeidiSQL and then imported the data on Server 2. The data imported fine, but the performance of the queries is worse by a factor of 10x. I went over the buffer size variables and all other "key" variables and they are the same or increased on Server 2. I tried changing the storage engine from MyIsam to Aria or InnoDB but the results were the same...I also optimized the whole DB but again no luck. Indexes are the same on both servers.

I then decided to host the DB back on the original server and just load the files from the new one....I exported the new DB (only data using insert ignore) and imported that SQL back to Server 1. Immediately after the import the original DB started performing slowly as well... Unless I use the original backup from when I moved the DB the first time, no matter how I update the DB to new data it starts performing poorly...

Example of query that takes 35 secs to run now when it used to take 3 secs:

select p.*,pd.ID detailID,s.title subject,s.displayTitle,s.memberPanCode,s.virtualDelivery,
                CASE WHEN (DATE_ADD(p.releaseDate, INTERVAL 2 WEEK) > NOW()) THEN 1 ELSE 0 END pNew,
            CASE WHEN(s.publicChoice=1) THEN s.memberPanCode ELSE '' END usableSubject,
            CASE WHEN(s.displayTitle=1) THEN s.ID ELSE '0' END subjectID 
        from sProduct p 
        inner join sProductDetail pd on pd.ID_sProduct=p.ID 
        left join sProductDetailWarehouse pdw on pdw.ID_sProductDetail=pd.ID 
        left join sProductDetailSubjectPrice pdsp on pdsp.ID_sProductDetail=pd.ID 
        left join sSubject s on (s.memberPanCode=pdsp.memberPanCode and s.shownOnSite=1) 
            where 
            (s.publicChoice=1 OR s.defaultSubject=1 OR s.memberPanCode='' OR s.memberPanCode IS NULL) 
            AND ((pd.ID > 0 AND s.displayTitle IS NOT NULL) OR (pd.ID IS NULL AND s.displayTitle IS NULL) OR (pd.ID > 0 and p.ID_sSupplier > 0) OR (pd.ID > 0 and pdsp.ID IS NULL) OR (pd.ID > 0 and s.displayTitle IS NULL)) 
            AND (DATE_ADD(NOW(), INTERVAL 1 DAY) > p.showDate)  
            AND (pdw.stock > 0 OR pd.stock > 0 OR (p.ID_sSupplier > 0 AND p.ID_sSupplier <> '3'))  
            and p.published IN (1,2) GROUP BY p.ID,s.memberPanCode order by p.showDate desc limit 3

DB structure can be found here: https://igabiba.si/images/biba_scheme.sql

Any idea what is there left to check? What can I do to solve this?

Thank you for helping



from MySQL to MariaDB - slow performance

No comments:

Post a Comment