• Hi folks, one of our mutual users noticed that the media library listing was very slow with EWWW IO installed. I couldn’t find the slow query anywhere in our code, so he investigated further and found it came from WP Optimize. Specifically wp-optimize/includes/class-updraft-smush-manager.php where the plugin queries the wp_ewwwio_images table.
    The queries run only include the attachment_id, for which there is no index/key because such results are not guaranteed to be accurate (due to potential ID conflicts with NextGEN or FlAGallery). The proper way to query the table for media library images is to include the ‘gallery’ column in the query, as we have a combined index for the attachment_id & gallery columns. For example, line 779 should be:
    $ewww_image = $wpdb->get_col("SELECT attachment_id FROM {$wpdb->prefix}ewwwio_images WHERE attachment_id={$image_id} AND gallery='media' LIMIT 1");

    I’ve tested the change myself, and the speedup from the correct query is dramatic. There looks to be one more query on line 800 too.

    Take care!

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘inefficient (very slow) query for EWWW IO history’ is closed to new replies.