• Resolved NielsV_E

    (@nielsv_e)


    Hi All,

    Since upgrade to new version, I expect hughe problems with mysql.
    Here’s the slow query log.

    This query is executed when clicking “Add Gallery / Images”.

    # Time: 140123 13:46:17
    # User@Host: @ localhost []
    # Query_time: 33.742712 Lock_time: 0.000104 Rows_sent: 1406 Rows_examined: 6492984
    use xxxxx;
    SET timestamp=1390481177;
    SELECT wp_ngg_gallery.* , wp_options.option_value AS ‘custom_post_id’, GROUP_CONCAT(CONCAT_WS(‘@@’, meta_key, meta_value)) AS ‘extras’ FROM wp_ngg_gallery LEFT OUTER JOIN wp_options ON wp_options.option_name = CONCAT(‘wp_ngg_gallery_’, wp_ngg_gallery.gid) LEFT OUTER JOIN wp_postmeta ON wp_postmeta.post_id = wp_options.option_value GROUP BY wp_ngg_gallery.gid;

    How can we avoid this querie is being executed or can we tune the tables?

    Niels

    https://www.ads-software.com/plugins/nextgen-gallery/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter NielsV_E

    (@nielsv_e)

    I made a dirty change in the mixin.netgen_table_extras.php …

    Line 153, function get_generated_query ()

    Added some limitations:
    $this->object->limit(20,0);
    $this->object->order_by($primary_key, “DESC”);

    We don’t use NextGen function for post_id’s (only use [ngggallery id=]), so I changed also the query:
    $sql = str_replace(‘FROM’, “, {$wpdb->options}.option_value AS ‘custom_post_id’, GROUP_CONCAT(CONCAT_WS(‘@@’, meta_key, meta_value)) AS ‘extras’ FROM”, $sql);

    in:
    $sql = str_replace(‘FROM’, “, ” AS ‘custom_post_id’, ” AS ‘extras’ FROM”, $sql);

    And also:
    $sql = str_replace($from, “{$from} LEFT OUTER JOIN {$wpdb->options} ON {$wpdb->options}.option_name = CONCAT(‘{$table_name}_’, {$primary_key}) LEFT OUTER JOIN {$wpdb->postmeta} ON {$wpdb->postmeta}.post_id = {$wpdb->options}.option_value “, $sql);

    $sql = str_replace($from, “{$from} LEFT OUTER JOIN {$wpdb->options} ON {$wpdb->options}.option_name = CONCAT(‘{$table_name}_’, {$primary_key})”, $sql);

    I only show the last 20 galleries when adding pictues to a gallery.
    Therefore also showing only the last 20 galleries in selectbox by Posts.

    Plugin Contributor photocrati

    (@photocrati)

    @nielsv_e – Thanks for your suggestion … we have also improved this part our our queries with our next (beta) release and expect it will have an over-all improvement with speed.

    – Cais.

    Anonymous User 88352

    (@anonymized-88352)

    I have also started to see MySQL slow query log entries lately; I can’t say if it started with NextGEN Gallery version 2.0.40. The site has about 800 images in 40 galleries. Here’s a sample:

    # Query_time: 14 Lock_time: 0 Rows_sent: 173 Rows_examined: 4431348
    use s******;
    SELECT galleryid, COUNT(*) as counter , wp_options.option_value AS ‘custom_post_id’, GROUP_CONCAT(CONCAT_WS(‘@@’, meta_key, meta_value)) AS ‘extras’ FROM wp_ngg_pictures LEFT OUTER JOIN wp_options ON wp_options.option_name = CONCAT(‘wp_ngg_pictures_’, wp_ngg_pictures.pid) LEFT OUTER JOIN wp_postmeta ON wp_postmeta.post_id = wp_options.option_value WHERE (galleryid IN (35, 38, 15, 16, 41, 17, 14, 43)) GROUP BY galleryid, wp_ngg_pictures.pid;

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Slow query – Nextgen’ is closed to new replies.