{"id":597680,"date":"2014-08-06T11:07:39","date_gmt":"2014-08-06T18:07:39","guid":{"rendered":"https:\/\/tri.be\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/"},"modified":"2014-08-25T20:37:32","modified_gmt":"2014-08-26T03:37:32","slug":"query-is-too-long-and-keeps-timing-out","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/","title":{"rendered":"Query is too long and keeps timing out."},"content":{"rendered":"<p>Hello,<\/p>\n<p>I reached out my hosting provider (WpEngine) first. I can&#8217;t access the backend of the website. I know I simply need to delete items, but I keep getting time-out errors, so I can&#8217;t get to the event section to delete them. Here is the note from WpEngine support:<\/p>\n<p>Alexander, Aug 06 11:39 AM:<br \/>\nHi Anthony,<\/p>\n<p>I&#8217;ve taken a look at the issue and here is what I found:<\/p>\n<p>I went to this page:<\/p>\n<p>http:\/\/boilercatholics.org\/wp-admin\/edit.php?post_type=tribe_events<\/p>\n<p>It didn&#8217;t error out but it took a long time to load.<\/p>\n<p>I then checked the apache error log and found this created at the time when I visited the page:<\/p>\n<p>[Wed Aug 06 16:13:45 2014] [error] [client 198.58.119.71] [WPE Monitoring] Slow mysql_query() call was running query:\\nSELECT SQL_CALC_FOUND_ROWS DISTINCT wp_posts.*, eventStart.meta_value as EventStartDate, eventEnd.meta_value as EventEndDate FROM wp_posts LEFT JOIN wp_postmeta as eventStart ON ( wp_posts.ID = eventStart.post_id AND eventStart.meta_key = &#8216;_EventStartDate&#8217; ) LEFT JOIN wp_postmeta as eventEnd ON ( wp_posts.ID = eventEnd.post_id AND eventEnd.meta_key = &#8216;_EventEndDate&#8217; ) LEFT JOIN wp_postmeta as tribe_event_end_date ON ( wp_posts.ID = tribe_event_end_date.post_id AND tribe_event_end_date.meta_key = &#8216;_EventEndDate&#8217; ) WHERE 1=1 AND wp_posts.post_type = &#8216;tribe_events&#8217; AND (wp_posts.post_status = &#8216;publish&#8217; OR wp_posts.post_status = &#8216;future&#8217; OR wp_posts.post_status = &#8216;draft&#8217; OR wp_posts.post_status = &#8216;pending&#8217; OR wp_posts.post_status = &#8216;private&#8217;) ORDER BY eventStart.meta_value DESC, eventEnd.meta_value DESC LIMIT 0, 20 \/* From [boilercatholics.org\/wp-admin\/edit.php?post_type=tribe_events] in [N\/A] *\/<br \/>\nI also checked the SQL slow query log &#8211; these are queries that took too long to complete and were shut down, and found several instances related to the events page. Here is an example:<\/p>\n<p># Thread_id: 19159341 Schema: wp_boilercatholic Last_errno: 0 Killed: 0<br \/>\n# Query_time: 3.375891 Lock_time: 0.000201 Rows_sent: 20 Rows_examined: 270269 Rows_affected: 0 Rows_read: 270269<br \/>\n# Bytes_sent: 8383<br \/>\nuse wp_boilercatholic;<br \/>\nSET timestamp=1407335259;<br \/>\nSELECT SQL_CALC_FOUND_ROWS DISTINCT wp_posts.*, eventStart.meta_value as EventStartDate, eventEnd.meta_value as EventEndDate FROM wp_posts LEFT JOIN wp_postmeta as eventStart ON ( wp_posts.ID = eventStart.post_id AND eventStart.meta_key = &#8216;_EventStartDate&#8217; ) LEFT JOIN wp_postmeta as eventEnd ON ( wp_posts.ID = eventEnd.post_id AND eventEnd.meta_key = &#8216;_EventEndDate&#8217; ) LEFT JOIN wp_postmeta as tribe_event_end_date ON ( wp_posts.ID = tribe_event_end_date.post_id AND tribe_event_end_date.meta_key = &#8216;_EventEndDate&#8217; ) WHERE 1=1 AND wp_posts.post_type = &#8216;tribe_events&#8217; AND (wp_posts.post_status = &#8216;publish&#8217; OR wp_posts.post_status = &#8216;future&#8217; OR wp_posts.post_status = &#8216;draft&#8217; OR wp_posts.post_status = &#8216;pending&#8217; OR wp_posts.post_status = &#8216;private&#8217;) ORDER BY eventStart.meta_value DESC, eventEnd.meta_value DESC LIMIT 0, 20 \/* From [boilercatholics.org\/wp-admin\/edit.php?post_type=tribe_events] in [N\/A] *\/;<br \/>\n# Time: 140806 14:30:42<br \/>\n# User@Host: boilercatholic[boilercatholic] @ localhost [127.0.0.1]<br \/>\n# Thread_id: 19159710 Schema: wp_boilercatholic Last_errno: 0 Killed: 0<br \/>\n# Query_time: 2.201473 Lock_time: 0.000201 Rows_sent: 5 Rows_examined: 134761 Rows_affected: 0 Rows_read: 134761<br \/>\n# Bytes_sent: 3627<br \/>\nSET timestamp=1407335442;<br \/>\nThis query tried to examine 134761 and exceeded the timeout threshold. This is the reason for why you were seeing the 504 gateway timeout errors.<\/p>\n<p>I see that Ethan Kennedy pointed this out in the chat when you originally started the ticket. Basically any activity that outputs information will require a query to database. Since database can be large, if the query is too broad then it could search through much more of the database than it really needs. Because of this, the query can exceed the timeout and generate 504 error.<\/p>\n<p>The solution to this is to make the queries more efficient so that they don&#8217;t exceed the timeout threshold.<\/p>\n<p>I see that you&#8217;re using The Events Calendar PRO plugin. Since it&#8217;s a premium plugin the developer should be able to assist you in making these queries more efficient. Sometimes it&#8217;s a matter of adjusting the plugin settings.<\/p>\n<p>Here is the link the plugin developer&#8217;s support page:<\/p>\n<p>https:\/\/theeventscalendar.com\/support\/?utm_medium=plugin-ecp<\/p>\n<p>If they require any additional information from us, we would be happy to provide that information.<\/p>\n<p>Hope that helps. Let us know if you have any questions. I can also give you a call if that might be easier for you.<\/p>\n<p>Regards,<\/p>\n","protected":false},"template":"","class_list":["post-597680","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Query is too long and keeps timing out.  -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Query is too long and keeps timing out.  -\" \/>\n<meta property=\"og:description\" content=\"Hello, I reached out my hosting provider (WpEngine) first. I can&#8217;t access the backend of the website. I know I simply need to delete items, but I keep getting time-out errors, so I can&#8217;t get to the event section to delete them. Here is the note from WpEngine support: Alexander, Aug 06 11:39 AM: Hi [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/\" \/>\n<meta property=\"article:modified_time\" content=\"2014-08-26T03:37:32+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/\",\"name\":\"Query is too long and keeps timing out. -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2014-08-06T18:07:39+00:00\",\"dateModified\":\"2014-08-26T03:37:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Calendar Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Events Calendar PRO\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Query is too long and keeps timing out.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Query is too long and keeps timing out.  -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/","og_locale":"en_US","og_type":"article","og_title":"Query is too long and keeps timing out.  -","og_description":"Hello, I reached out my hosting provider (WpEngine) first. I can&#8217;t access the backend of the website. I know I simply need to delete items, but I keep getting time-out errors, so I can&#8217;t get to the event section to delete them. Here is the note from WpEngine support: Alexander, Aug 06 11:39 AM: Hi [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/","article_modified_time":"2014-08-26T03:37:32+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/","name":"Query is too long and keeps timing out. -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2014-08-06T18:07:39+00:00","dateModified":"2014-08-26T03:37:32+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/query-is-too-long-and-keeps-timing-out\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Calendar Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/"},{"@type":"ListItem","position":4,"name":"Events Calendar PRO","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/"},{"@type":"ListItem","position":5,"name":"Query is too long and keeps timing out."}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/597680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/597680\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=597680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}