• Hey,
    I’ve been debugging slow querys on my wordpress site and i’ve noticed that calling $dynamic_featured_image->get_featured_images() is really slow.

    It comes down to this query:
    SELECT post_id FROM ' . $this->db->postmeta . ' WHERE meta_key = %s AND meta_value = %s
    Called from: get_image_id();
    this query on my site takes 12 seconds… But by adding a simple condition on a keyed field solves this down to basically nothing

    I suggest changing the code to the following:

    $row = $this->execute_query( $this->db->prepare( 'SELECT post_id FROM ' . $this->db->postmeta . ' WHERE meta_key = %s AND meta_value = %s', '_wp_attached_file', $image_url ) );

    • This topic was modified 7 years, 6 months ago by fullbundle.
  • The topic ‘Very Slow Query on large postmeta tables’ is closed to new replies.