1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Slow Website Help

Discussion in 'MySQL' started by mhrlive, Jan 20, 2013.

  1. #1
    Ok hello everyone,
    First of all Im not a pro when talking about mysql, I have a website/script running fine until few days ago the website became so slow, tried to optimize everything from httpd, my.ini and optimizing databases, I believe that the problem of this is coding mysql so please help me on this Im a beginner,
    Here is the slow.log file :
    # Time: 130118 12:09:09
    # User@Host: root[root] @ localhost []
    # Query_time: 11.611585  Lock_time: 0.000033 Rows_sent: 0  Rows_examined: 509
    SET timestamp=1358500149;
    UPDATE `stats_dynamic` SET `time_end` = UNIX_TIMESTAMP() WHERE `user_code` = '4b70f7d4' AND `href` = 'http://albtvlive.com/' AND `time_start` = 1358500130 AND `visitor_id` = 3569909453;
    # Time: 130119  0:01:10
    # User@Host: root[root] @ localhost []
    # Query_time: 12.136366  Lock_time: 0.003301 Rows_sent: 0  Rows_examined: 65704452
    SET timestamp=1358542870;
    INSERT INTO `stats_hours` (`date_start`,`user_code`, `min_online`,`max_online`,`avg_online`)
    SELECT
        CONVERT( @ts, SIGNED) AS `date_start`,
        `dt`.`user_code`,
        MIN(IF (`dt`.`cnt2` IS NULL, 0, `dt`.`cnt2`)) AS `min_online`,
        MAX(IF (`dt`.`cnt2` IS NULL, 0, `dt`.`cnt2`)) AS `max_online`,
        AVG(IF (`dt`.`cnt2` IS NULL, 0, `dt`.`cnt2`)) AS `avg_online`
    FROM
        (SELECT
            `sh7`.`user_code`,
                `it_rest`.`it`,
                (SELECT
                    CONVERT( COUNT(DISTINCT `sh3`.`visitor_id`), SIGNED ) AS `cnt`
                FROM
                    (SELECT
                    `sh4`.`visitor_id`,
                        `sh4`.`time_start`,
                        `sh4`.`time_end`,
                        `sh4`.`user_code`
                FROM
                    `stats_history` as `sh4`
                WHERE
                    `sh4`.`time_start` < @ts+3600 AND `sh4`.`time_end` > @ts) AS `sh3`
                WHERE
                    `it_rest`.`it` BETWEEN `sh3`.`time_start` AND `sh3`.`time_end` AND `sh3`.`user_code` = `sh7`.`user_code`
                GROUP BY `sh3`.`user_code`,`it_rest`.`it`) AS `cnt2`
        FROM
            (SELECT
            @it := @it+@step as `it`
        FROM
            `ints`
        WHERE
            @it < @te) AS `it_rest`
        CROSS JOIN (SELECT
            DISTINCT `user_code`
        FROM
            `stats_history`
        WHERE
            `time_start` < @ts+3600 AND `time_end` > @ts) AS `sh7`) AS `dt`
    GROUP BY `dt`.`user_code`;
    /usr/libexec/mysqld, Version: 5.5.29-cll (MySQL Community Server (GPL) by Atomicorp). started with:
    Tcp port: 0  Unix socket: /var/lib/mysql/mysql.sock
    Time                Id Command    Argument
    /usr/libexec/mysqld, Version: 5.5.29-cll (MySQL Community Server (GPL) by Atomicorp). started with:
    Tcp port: 0  Unix socket: /var/lib/mysql/mysql.sock
    Time                Id Command    Argument
    /usr/libexec/mysqld, Version: 5.5.29-cll (MySQL Community Server (GPL) by Atomicorp). started with:
    Tcp port: 0  Unix socket: /var/lib/mysql/mysql.sock
    Time                Id Command    Argument
    /usr/libexec/mysqld, Version: 5.5.29-cll (MySQL Community Server (GPL) by Atomicorp). started with:
    Tcp port: 0  Unix socket: /var/lib/mysql/mysql.sock
    Time                Id Command    Argument
    /usr/libexec/mysqld, Version: 5.5.29-cll (MySQL Community Server (GPL) by Atomicorp). started with:
    Tcp port: 0  Unix socket: /var/lib/mysql/mysql.sock
    Time                Id Command    Argument
    /usr/libexec/mysqld, Version: 5.5.29-cll (MySQL Community Server (GPL) by Atomicorp). started with:
    Tcp port: 0  Unix socket: /var/lib/mysql/mysql.sock
    Time                Id Command    Argument
    /usr/libexec/mysqld, Version: 5.5.29-cll (MySQL Community Server (GPL) by Atomicorp). started with:
    Tcp port: 0  Unix socket: /var/lib/mysql/mysql.sock
    Time                Id Command    Argument
    /usr/libexec/mysqld, Version: 5.5.29-cll (MySQL Community Server (GPL) by Atomicorp). started with:
    Tcp port: 0  Unix socket: /var/lib/mysql/mysql.sock
    Time                Id Command    Argument
    /usr/libexec/mysqld, Version: 5.5.29-cll (MySQL Community Server (GPL) by Atomicorp). started with:
    Tcp port: 0  Unix socket: /var/lib/mysql/mysql.sock
    Time                Id Command    Argument
    /usr/libexec/mysqld, Version: 5.5.29-cll (MySQL Community Server (GPL) by Atomicorp). started with:
    Tcp port: 0  Unix socket: /var/lib/mysql/mysql.sock
    Time                Id Command    Argument
    /usr/libexec/mysqld, Version: 5.5.29-cll (MySQL Community Server (GPL) by Atomicorp). started with:
    Tcp port: 0  Unix socket: /var/lib/mysql/mysql.sock
    Time                Id Command    Argument
    PHP:
    That repeat alot, I tried APC and didn't help, I'll provide any other info in case you need.
    Thanks
     
    mhrlive, Jan 20, 2013 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    Unless the code changed around the time the site slowed down, it's not the code that slowing the site down. Unless the database got a lot larger around the time the site slowed down, it's not the database that's slowing the site down.

    Things don't just change because they want to. Something changed, and that change slowed the site down. Fixing other things that may or may not be broken isn't going to fix the problem. You have to find the problem before you can fix it.

    Did the version of MySQL change? Did the version of PHP change? Did they move you to a more heavily loaded server (or did the server you're on get more heavily loaded)? Those are the kinds of things you have to find out first. Changing the tires won't make the car go faster if the plugs are fouled.
     
    Rukbat, Jan 22, 2013 IP