将MySQL从5.0.67升级到5.5.44-MariaDB后性能显着下降

时间:2016-03-24 18:54:10

标签: mysql mariadb

我最近将MySQL数据库从5.0.67迁移到5.5.44-MariaDB,我有一个查询,在5.0.67中执行不到一秒,但在5.5.44中需要超过100秒。

在我开始重写查询之前,我想找到两台服务器之间的区别,我的猜测是它可能是一个在MariaDB中不理想但我找不到它的设置。

5.0.67的配置:

set-variable = innodb_buffer_pool_size=2M
set-variable = innodb_additional_mem_pool_size=500K
set-variable = innodb_log_buffer_size=500K
set-variable = innodb_thread_concurrency=2
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
timezone=America/Chicago

set-variable = innodb_buffer_pool_size=2M
set-variable = innodb_additional_mem_pool_size=500K
set-variable = innodb_log_buffer_size=500K
set-variable = innodb_thread_concurrency=2

#increse lock wait timout
innodb_lock_wait_timeout = 120

5.5.44的配置:

key_buffer_size = 16M
max_allowed_packet = 1M

sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M

innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
innodb_log_buffer_size = 8M

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

查询:

SELECT
    node.user_id,
    node.user_id as id,
    node.name,
    node.status,
    node.left_id,
    node.right_id,
    node.locked,
    CONCAT(   node.name, ' ', node.surname) as fullname,
    (COUNT(parent.name) - (sub_tree.level + 1)) AS level
FROM
    users AS node ,
    users AS parent  ,
    users AS sub_parent  ,
    (
    SELECT
        node.name,
        node.user_id,
        (COUNT(parent.name) - 1) AS level
    FROM
        users AS node,
        users AS parent 
    WHERE
        node.left_id BETWEEN parent.left_id AND parent.right_id
    AND
        node.user_id = '29151'
    GROUP BY node.name
    ORDER BY node.left_id
    ) AS sub_tree
WHERE
    node.left_id BETWEEN parent.left_id AND parent.right_id
AND
    node.left_id BETWEEN sub_parent.left_id AND sub_parent.right_id
AND
    sub_parent.user_id = sub_tree.user_id      
GROUP BY
    node.user_id
HAVING
    1 = 1
    and node.locked = 0
      and level  in ( 1,2,3,4)          
 ORDER BY node.left_id ;

0 个答案:

没有答案