{"id":1136272,"date":"2016-07-06T14:39:34","date_gmt":"2016-07-06T21:39:34","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/slow-query-causing-site-to-go-down\/"},"modified":"2016-07-06T14:39:34","modified_gmt":"2016-07-06T21:39:34","slug":"slow-query-causing-site-to-go-down","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/slow-query-causing-site-to-go-down\/","title":{"rendered":"slow query causing site to go down"},"content":{"rendered":"<p>Hi There, <\/p>\n<p>I&#8217;ve had a look at some of the other support forums as this seems to have been a pretty common issue.   <\/p>\n<p>The Query below seems to use up 99% of the servers resources every time it runs and if more than one user tries to visit a calendar event page the site basically dies.  <\/p>\n<p># Time: 160706 10:13:49<br \/>\n# User@Host: ytn_db[ytn_db] @ localhost []<br \/>\n# Thread_id: 1120  Schema: ytn_db  QC_hit: No<br \/>\n# Query_time: 20.848194  Lock_time: 0.000117  Rows_sent: 34  Rows_examined: 7667238<br \/>\n# Rows_affected: 0<br \/>\nSET timestamp=1467825229;<br \/>\nSELECT tribe_event_start.post_id as ID,<br \/>\n                                                tribe_event_start.meta_value as EventStartDate,<br \/>\n                                                tribe_event_end_date.meta_value as EventEndDate<br \/>\n                                FROM wp_postmeta AS tribe_event_start<br \/>\n                                LEFT JOIN wp_posts ON tribe_event_start.post_id = wp_posts.ID<br \/>\n                                LEFT JOIN wp_postmeta as tribe_event_end_date ON ( tribe_event_start.post_id = tribe_event_end_date.post_id AND tribe_event_end_date.meta_key = &#8216;_EventEndDate&#8217; )<br \/>\n                                WHERE  tribe_event_start.meta_key = &#8216;_EventStartDate&#8217;<br \/>\n                                AND ( (tribe_event_start.meta_value &gt;= &#8216;2016-06-27 00:00:00&#8217; AND  tribe_event_start.meta_value &lt;= &#8216;2016-07-31 23:59:59&#8217;)<br \/>\n                                        OR (tribe_event_start.meta_value &lt;= &#8216;2016-06-27 00:00:00&#8217; AND tribe_event_end_date.meta_value &gt;= &#8216;2016-06-27 00:00:00&#8217;)<br \/>\n                                        OR ( tribe_event_start.meta_value &gt;= &#8216;2016-06-27 00:00:00&#8217; AND  tribe_event_start.meta_value &lt;= &#8216;2016-07-31 23:59:59&#8217;)<br \/>\n                                )<br \/>\n                                AND wp_posts.post_status IN(&#8216;publish&#8217;,&#8217;private&#8217;)<br \/>\n                                ORDER BY wp_posts.menu_order ASC, DATE(tribe_event_start.meta_value) ASC, TIME(tribe_event_start.meta_value) ASC;<\/p>\n<p>I noticed on some other threads that selecting the cache option in the admin settings has helped in some cases but it doesn&#8217;t seem to do the trick here.  <\/p>\n<p>In an attempt to speed things up we tried indexing those particular tables that get queried, as they are not usually indexed by default, but that didn&#8217;t seem to help as it looks like it is building a temporary table with all the joins every time and then scanning that which is a huge amount to go through and consequently quite slow.  <\/p>\n<p>There are currently just over 2000 events and were hoping that removing them will help the issue.  I&#8217;ve also noticed that wpengine has given some people grief with this plugin.  We are NOT using Wp engine but if there are any settings we can adjust on our server to help solve the issue let me know. <\/p>\n<p>If you have any other suggestions, patches or ideas please let me know. <\/p>\n<p>You can see the site here http:\/\/www.yourtownnews.ca\/<\/p>\n<p>I&#8217;ve currently had to disable the plugin in order to keep the site live.  Let me know if you need it active to do any investigation. <\/p>\n","protected":false},"template":"","class_list":["post-1136272","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>slow query causing site to go down -<\/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\/slow-query-causing-site-to-go-down\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"slow query causing site to go down -\" \/>\n<meta property=\"og:description\" content=\"Hi There, I&#8217;ve had a look at some of the other support forums as this seems to have been a pretty common issue. The Query below seems to use up 99% of the servers resources every time it runs and if more than one user tries to visit a calendar event page the site basically [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/slow-query-causing-site-to-go-down\/\" \/>\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=\"2 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\/slow-query-causing-site-to-go-down\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/slow-query-causing-site-to-go-down\/\",\"name\":\"slow query causing site to go down -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2016-07-06T21:39:34+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/slow-query-causing-site-to-go-down\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/slow-query-causing-site-to-go-down\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/slow-query-causing-site-to-go-down\/#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\":\"slow query causing site to go down\"}]},{\"@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":"slow query causing site to go down -","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\/slow-query-causing-site-to-go-down\/","og_locale":"en_US","og_type":"article","og_title":"slow query causing site to go down -","og_description":"Hi There, I&#8217;ve had a look at some of the other support forums as this seems to have been a pretty common issue. The Query below seems to use up 99% of the servers resources every time it runs and if more than one user tries to visit a calendar event page the site basically [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/slow-query-causing-site-to-go-down\/","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/slow-query-causing-site-to-go-down\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/slow-query-causing-site-to-go-down\/","name":"slow query causing site to go down -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2016-07-06T21:39:34+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/slow-query-causing-site-to-go-down\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/slow-query-causing-site-to-go-down\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/slow-query-causing-site-to-go-down\/#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":"slow query causing site to go down"}]},{"@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\/1136272","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\/1136272\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1136272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}