WordPress.org

Ready to get started?Download WordPress

Forums

Slow Queries - Site Crash (8 posts)

  1. jeremib
    Member
    Posted 4 years ago #

    It seems there's this one query,
    SELECT SQL_CALC_FOUND_ROWS distinct wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_term_taxonomy ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') AND NOT EXISTS (SELECT * FROM wp_term_relationships JOIN wp_term_taxonomy ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id WHERE wp_term_relationships.object_id = wp_posts.ID AND wp_term_taxonomy.taxonomy = 'category' AND wp_term_taxonomy.term_id IN (89) ) ORDER BY wp_posts.post_date DESC LIMIT 0, 50;

    That is locking up my database and bringing down my site, at least once a day. When I look in the slow queries log, it's full of them.

    # Time: 091016 8:56:50
    # User@Host: mrsec_wp[mrsec_wp] @ localhost []
    # Query_time: 13 Lock_time: 0 Rows_sent: 50 Rows_examined: 185675
    use mrsec_wp;
    SELECT SQL_CALC_FOUND_ROWS distinct wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_term_taxonomy ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND NOT EXISTS (SELECT * FROM wp_term_relationships JOIN wp_term_taxonomy ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id WHERE wp_term_relationships.object_id = wp_posts.ID AND wp_term_taxonomy.taxonomy = 'category' AND wp_term_taxonomy.term_id IN (89) ) ORDER BY wp_posts.post_date DESC LIMIT 0, 50;

    Any thoughts on how I can optimize this query? And is this a built in query, or from plugin?

  2. Mark / t31os
    Moderator
    Posted 4 years ago #

    wp-includes/query.php - Line 2249 +
    The main posts query..

    That's the only place the text "SQL_CALC_FOUND_ROWS" exists..

  3. jeremib
    Member
    Posted 4 years ago #

    So can anything be done about the speed?

    It takes approx 13 seconds to execute this query. I have 28k records.

  4. Mark / t31os
    Moderator
    Posted 4 years ago #

    Nothing i can suggest unfortunately, i'm only a self taught coder..

    I'd suggest posting your question up on the hackers mailing list.
    http://lists.automattic.com/mailman/listinfo/wp-hackers

    I think you'll find more users that handle large sites and are WordPress literate hanging around on there.

  5. jeremib
    Member
    Posted 4 years ago #

    Thanks. I posted the question there.

  6. evo252
    Member
    Posted 4 years ago #

    Hello jeremib,
    I have the same pb, have you get resolve the bug ???
    If yes, please let me know !!

  7. popokolok
    Member
    Posted 4 years ago #

    Anything new on that? Thanks!

  8. stenspect
    Member
    Posted 4 years ago #

    I have the same problem. What plugins are you running? Any similar?

    I have the following:
    Askimet
    Disqus
    Script Enabler
    Feed Wrangler
    Google XML Sitemaps
    RYO Category Visibility
    ShareThis
    unFocus.Insensitivity
    WP YouTube

Topic Closed

This topic has been closed to new replies.

About this Topic