Support » Plugin: NextGEN Gallery - WordPress Gallery Plugin » Too many rows in wp_ngg_table causing CPU spikes

  • I’ve been a long time user of nextgen gallery with minimal issues in the past so I was really surprised to learn from my host (hostgator) that nextgen was causing excessive cpu usage on our hosting platform. Here’s a portion of the recent message I received from one of their system admins:

    “It appears the account is going over the MySQL row read limit. I enabled logging for a bit and browsed the site and found this kind of query repeated frequently:

    [-] allmonst_wrdp3 | 44272 | | Using where | SELECT image_slug FROM wp_ngg_pictures WHERE image_slug = ‘hooked-21’ AND NOT pid = 0 LIMIT 1

    The 1st column is the database name, the second is the number of rows read, the last column shows the query. As you can see the query is reading over 40,000 rows to load one image from the wp_ngg_table, which appears to be the table for the plugin called NextGEN Gallery. You may want to add some indexes to that MySQL table, or consider replacing that plugin with another. If possible, I would suggest checking with the plugin developer for direct assistance.”

    Has anyone else encountered similar issues, and if so was there any resolution? I used the plugin to maintain 400+ photo galleries on my site, totaling over 44,000 photos. I’d hate to have to move everything away from nextgen but I don’t know MySQL, so I have no idea how to fix it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author photocrati


    @horizonofchaos – Thanks for letting the community know about this potential MySQL issue. I (Cais) use HostGator myself and have not seen any issues but I also do not have anywhere near the total images on any of my sites using NextGEN Gallery.

    We would greatly appreciate it if you could send us a bug report about this issue on your site. Please use the form on this page:

    Feel free to add MySQL as part of the “Issue Title”, too.

    We have seen reports of other MySQL issues that may be related. If any other readers are having similar issues please feel free to submit your own Bug Report as well.


    – Cais.

    PS: This is being addressed as a high priority, but in the meantime you may see some relief with the following:
    Go to Gallery > Settings > Miscellaneous > Clear Image Cache.

    Thanks Cais. Bug report has been submitted.

    I used this plugin for a long time, but it seems, that I can’t do it after v2.0. Did you test it at all?

    Simple lines of code in footer.php:

        echo get_num_queries() . " queries in "; timer_stop(1);
        echo " sec., memory: ".round(memory_get_usage()/1024/1024, 2)."mb";

    And I have these results:

    • 29 queries in 0.346 sec., memory: 24.31mb – post without plugin
    • 32 queries in 0.594 sec., memory: 31.53mb – post after installed and activated plugin (no galleries at all)
    • 54 queries in 0.690 sec., memory: 34.08mb – post with gallery-shortcode (image tag), but gallery is empty
    • 123 queries in 1.232 sec., memory: 34.51mb – post with gallery-shortcode (17 photos in gallery)
    • 225 queries in 1.176 sec., memory: 34.71mb – post with gallery-shortcode (34 photos in gallery (+17 images))
    • 355 queries in 1.419 sec., memory: 34.9mb – post with gallery-shortcode (51 photos in gallery (+17 images))

    As you can see, plugin (v 2.0.33) still has serious problems with database queries.

    I had no luck with any of the updates. I was able to get my site back to functioning by switching to nextcellent instead of nextgen though. Hopefully nextgen will get the problem fixed in the future. It was a fantastic plugin for so long.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Too many rows in wp_ngg_table causing CPU spikes’ is closed to new replies.