{"action":"created","issue":{"url":"https://api.github.com/repos/Yoast/wordpress-seo/issues/3010","labels_url":"https://api.github.com/repos/Yoast/wordpress-seo/issues/3010/labels{/name}","comments_url":"https://api.github.com/repos/Yoast/wordpress-seo/issues/3010/comments","events_url":"https://api.github.com/repos/Yoast/wordpress-seo/issues/3010/events","html_url":"https://github.com/Yoast/wordpress-seo/issues/3010","id":111292969,"number":3010,"title":"Limit SQL Call When Post Has Large Number of Attachments","user":{"login":"amboutwe","id":8060612,"avatar_url":"https://avatars.githubusercontent.com/u/8060612?v=3","gravatar_id":"","url":"https://api.github.com/users/amboutwe","html_url":"https://github.com/amboutwe","followers_url":"https://api.github.com/users/amboutwe/followers","following_url":"https://api.github.com/users/amboutwe/following{/other_user}","gists_url":"https://api.github.com/users/amboutwe/gists{/gist_id}","starred_url":"https://api.github.com/users/amboutwe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amboutwe/subscriptions","organizations_url":"https://api.github.com/users/amboutwe/orgs","repos_url":"https://api.github.com/users/amboutwe/repos","events_url":"https://api.github.com/users/amboutwe/events{/privacy}","received_events_url":"https://api.github.com/users/amboutwe/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Yoast/wordpress-seo/labels/enhancement","name":"enhancement","color":"bfe5bf"},{"url":"https://api.github.com/repos/Yoast/wordpress-seo/labels/question","name":"question","color":"cc317c"},{"url":"https://api.github.com/repos/Yoast/wordpress-seo/labels/xml%20sitemap","name":"xml sitemap","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-13T23:33:08Z","updated_at":"2015-10-15T14:43:08Z","closed_at":null,"body":"From premium user:\r\n\r\nI have noticed that recently we are seeing errors during sitemap generation. We have a rather large site with many posts and, more relevant to this issue, many attachments. \r\n\r\nThe errors we are seeing occur in the function WPSEO_Sitemaps->do_attachment_ids_caching (wordpress-seo-premium\\inc\\class-sitemaps.class.php:1457), on lines 1463 and 1464, the calls to _prime_post_caches and update_meta_cache. each of these calls generates a query containing an IN operator following by, in SQL Array notation, the ID of every attachment and thumbnail ever posted to the site - the query is 18,000-20,000 characters long, and our host, WPEngine, kills it as a result. Most other queries generated by this class are limited by the WPSEO_Sitemaps->max_entries property, which we have set accordingly to prevent time outs. \r\n\r\n**Error Log Entry**\r\nKILLED QUERY (18471 characters long generated in Path_to_WordPress/wp-content/plugins/wordpress-seo-premium/inc/class-sitemaps.php:1463): SELECT wp_posts.* FROM wp_posts.* FROM wp_posts WHERE ID IN ( [list of many attachment ids] )\r\n\r\nWould you consider, in a future version, applying this same restriction to this method? At the end of the day our sitemaps ARE generating fine anyway, it would seem. I have not yet been able to tell if this is because we have excluded attachments from sitemaps, or because it later falls back to uncached queries, what with the cache priming having failed. If the latter, then it will be a performance hit for us, but either way it certainly is clogging the logs at current. Also, if it is the former, it would be good if either automatically (based on attachments being excluded) or based on an option in the sitemaps menu we could disable the running of this method at all, seeing as it does not seem to be required."},"comment":{"url":"https://api.github.com/repos/Yoast/wordpress-seo/issues/comments/148407626","html_url":"https://github.com/Yoast/wordpress-seo/issues/3010#issuecomment-148407626","issue_url":"https://api.github.com/repos/Yoast/wordpress-seo/issues/3010","id":148407626,"user":{"login":"Rarst","id":737584,"avatar_url":"https://avatars.githubusercontent.com/u/737584?v=3","gravatar_id":"","url":"https://api.github.com/users/Rarst","html_url":"https://github.com/Rarst","followers_url":"https://api.github.com/users/Rarst/followers","following_url":"https://api.github.com/users/Rarst/following{/other_user}","gists_url":"https://api.github.com/users/Rarst/gists{/gist_id}","starred_url":"https://api.github.com/users/Rarst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rarst/subscriptions","organizations_url":"https://api.github.com/users/Rarst/orgs","repos_url":"https://api.github.com/users/Rarst/repos","events_url":"https://api.github.com/users/Rarst/events{/privacy}","received_events_url":"https://api.github.com/users/Rarst/received_events","type":"User","site_admin":false},"created_at":"2015-10-15T14:43:08Z","updated_at":"2015-10-15T14:43:08Z","body":"I won't even have a remote idea on this until query audit in #2787 is worked on.\r\n\r\nI know a lot of that code is specifically evolved to handle very large amounts of posts (otherwise it would just all be WP API). I'd inquire with host if there is _actual_ performance problem with those queries or it's just arbitrary limitation they stuffed in."}}