WordPress.org

Make WordPress Core

Opened 7 weeks ago

Closed 6 weeks ago

#52722 closed defect (bug) (invalid)

Long running query causing site down

Reported by: naveenbos1 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description (last modified by peterwilsoncc)

We have a site that is running on WordPress 5.2.9 and it is continuously site went down at 3 AM central every day due to running a long query on WordPress

We did not find this query on the theme or plugin, Indly help to identify the issue.

Query | 42546 | Sending data |

SELECT Count(*)
FROM   sw_wp_posts
       LEFT JOIN sw_wp_term_relationships
              ON ( sw_wp_posts.id = sw_wp_term_relationships.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt1
              ON ( sw_wp_posts.id = tt1.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt2
              ON ( sw_wp_posts.id = tt2.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt3
              ON ( sw_wp_posts.id = tt3.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt4
              ON ( sw_wp_posts.id = tt4.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt5
              ON ( sw_wp_posts.id = tt5.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt6
              ON ( sw_wp_posts.id = tt6.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt7
              ON ( sw_wp_posts.id = tt7.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt8
              ON ( sw_wp_posts.id = tt8.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt9
              ON ( sw_wp_posts.id = tt9.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt10
              ON ( sw_wp_posts.id = tt10.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt11
              ON ( sw_wp_posts.id = tt11.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt12
              ON ( sw_wp_posts.id = tt12.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt13
              ON ( sw_wp_posts.id = tt13.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt14
              ON ( sw_wp_posts.id = tt14.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt15
              ON ( sw_wp_posts.id = tt15.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt16
              ON ( sw_wp_posts.id = tt16.object_id )
       LEFT JOIN sw_wp_term_relationships AS tt17
              ON ( sw_wp_posts.id = tt17.object_id )
WHERE  1 = 1
       AND ( ( sw_wp_term_relationships.term_taxonomy_id IN ( 8 )
               AND tt1.term_taxonomy_id IN ( 28 )
               AND tt2.term_taxonomy_id IN ( 59 ) )
              OR ( tt3.term_taxonomy_id IN ( 8 )
                   AND tt4.term_taxonomy_id IN ( 28 )
                   AND tt5.term_taxonomy_id IN ( 20 ) )
              OR ( tt6.term_taxonomy_id IN ( 6 )
                   AND tt7.term_taxonomy_id IN ( 28 )
                   AND tt8.term_taxonomy_id IN ( 59 ) )
              OR ( tt9.term_taxonomy_id IN ( 6 )
                   AND tt10.term_taxonomy_id IN ( 28 )
                   AND tt11.term_taxonomy_id IN ( 20 ) )
              OR ( tt12.term_taxonomy_id IN ( 7 )
                   AND tt13.term_taxonomy_id IN ( 28 )
                   AND tt14.term_taxonomy_id IN ( 59 ) )
              OR ( tt15.term_taxonomy_id IN ( 7 )
                   AND tt16.term_taxonomy_id IN ( 28 )
                   AND tt17.term_taxonomy_id IN ( 20 ) ) )
       AND sw_wp_posts.post_type = 'gallery'
       AND ( sw_wp_posts.post_status = 'publish'
              OR sw_wp_posts.post_status = 'acf-disabled'
              OR sw_wp_posts.post_status = 'future'
              OR sw_wp_posts.post_status = 'draft'
              OR sw_wp_posts.post_status = 'pending' )  

--

Edited to format SQL query -- @peterwilsoncc

Change History (3)

#1 @naveenbos1
7 weeks ago

  • Summary changed from Long rinning query causing site down to Long running query causing site down

#2 @peterwilsoncc
6 weeks ago

  • Description modified (diff)

#3 @peterwilsoncc
6 weeks ago

  • Keywords needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Severity changed from critical to normal
  • Status changed from new to closed

Hi @naveenbos1 and welcome to Trac!

I've reviewed the taxonomy queries WordPress core generates and the query you report doesn't appear to be coming from Core. I suspect it's a plugin (possibly an image gallery plugin due to the post_type but I can't be sure) adding multiple tax_query arguments to WP_Query.

Unfortunately Trac is used for development of WordPress software itself, rather than assisting with sites. You'll be able to find people much more able to help you in the WordPress Support forums.

As this appears to be plugin related, I'm going to close this off for now as invalid. In this case, that's just trac's unfriendly term to indicate I've referred you to a team better suited to help.

Note: See TracTickets for help on using tickets.