• Hi
    Everytime I open the ad-places page or open an specific ad-place to view the ads it will take up to a minute to open and the database goes and website are down meanwhile.
    I have 27 ad-places and there are about 130 ads in the system (7 active).

    Error log is empty. My guess is that the plugin is sending a heavy database query that locks everything.
    Can you think of something that could be the issue?

    WordPress Version: 3.6.1
    SAM Version: 2.2.80
    SAM DB Version: 2.6
    PHP Version: 5.3.28
    MySQL Version: 5.1.54-log
    Memory Limit: 128M

    Thanks,
    Andri

    https://www.ads-software.com/plugins/simple-ads-manager/

Viewing 6 replies - 1 through 6 (of 6 total)
  • This is definitely a significant problem. If you have more than 10 ads or so, it will temporarily crash the site because of how much memory it uses. Inefficient SQL queries seems to be the culprit. Anyone interested in rewriting the mysql interactions of this plugin?

    I can confirm that it is a problem with inefficient queries. If you remove lines 202 to 206 (see code block below) in list.admin.class.php, it will fix the loading issue. There’s a bunch of CPU-intensive mathematical operations being performed on the columns in those lines. The only detriment to deleting them is that you won’t see the hits and total hits columns displayed on the “ad places” page, but you can get those stats from each ad individually (there’s really no need to have them display there).

    @patch_hits := (IFNULL((SELECT COUNT(*) FROM $sTable ss WHERE (EXTRACT(YEAR_MONTH FROM NOW()) = EXTRACT(YEAR_MONTH FROM ss.event_time)) AND ss.id = 0 AND ss.pid = sp.id AND ss.event_type = 0), 0)) AS patch_hits,
                          (IFNULL((SELECT COUNT(*) FROM $sTable ss WHERE (EXTRACT(YEAR_MONTH FROM NOW()) = EXTRACT(YEAR_MONTH FROM ss.event_time)) AND ss.id > 0 AND ss.pid = sp.id AND ss.event_type = 0), 0) + IFNULL(@patch_hits, 0)) as total_ad_hits,
                          (IFNULL((SELECT SUM(IF(sa.cpm > 0, IFNULL((SELECT COUNT(*) FROM $sTable ss WHERE (EXTRACT(YEAR_MONTH FROM NOW()) = EXTRACT(YEAR_MONTH FROM ss.event_time)) AND ss.id = sa.id AND ss.pid = sa.pid AND ss.event_type = 0), 0) * sa.cpm / 1000, 0)) FROM $aTable sa WHERE sa.pid = sp.id), 0)) AS e_cpm,
                          (IFNULL((SELECT SUM(IF(sa.cpc > 0, IFNULL((SELECT COUNT(*) FROM $sTable ss WHERE (EXTRACT(YEAR_MONTH FROM NOW()) = EXTRACT(YEAR_MONTH FROM ss.event_time)) AND ss.id = sa.id AND ss.pid = sa.pid AND ss.event_type = 1), 0) * sa.cpc, 0)) FROM $aTable sa WHERE sa.pid = sp.id), 0)) AS e_cpc,
                          (IFNULL((SELECT SUM(IF(sa.ad_schedule AND sa.per_month > 0, DATEDIFF(CURDATE(), sa.ad_start_date) * sa.per_month / 30, 0)) FROM $aTable sa WHERE sa.pid = sp.id), 0)) AS e_month,

    it seems the plugin developer is no longer offering support. I hope this post helps someone!

    P.S. I should also note that if you have php notices/warnings enabled on your server, you might receive notices and/or warnings for undefined variables… to remedy that, you can turn off php warnings, set those variables to null values, or you could delete any references to said variables.

    Thank you, cscott5288!

    This solved the problem and I was able to open Ads Places without having MySQL database to crash!

    Do you know what and where I can remove the similar so that it doesn’t do the counting when looking within the ads place?

    No problem, jf1982.

    A while back I went through the whole plugin and sanitized it of any code which was over-taxing on mysql. For instance on the ad places page, if you have too many on one page, it will crash. I’ve uploaded my sanitized version here:
    deadcaterpillar.com/simple-ads-manager.zip

    Simply overwrite all the files in your plugin’s directory with the files in the zip.

    hope that helps you out!

    I should note that the version I uploaded might not be the version you are using. If they are different versions, you might want to switch to my version. def backup your files before trying anything.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Database goes down everytime I open the Ad-places page’ is closed to new replies.