{"id":19017303,"date":"2026-09-11T06:59:32","date_gmt":"2026-09-11T06:59:32","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/poorly-performing-code-in-analytics-data-collector\/"},"modified":"2026-09-11T06:59:32","modified_gmt":"2026-09-11T06:59:32","slug":"poorly-performing-code-in-analytics-data-collector","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/poorly-performing-code-in-analytics-data-collector\/","title":{"rendered":"Poorly Performing Code in Analytics\/Data Collector"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hello,<br \/>The <code>wp-content\/plugins\/embedpress\/EmbedPress\/Includes\/Classes\/Analytics\/Data_Collector.php<\/code> contains this code snippet:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Shortcode: posts containing &#091;embedpress*] shortcodes<br \/>$shortcode_count = (int) $wpdb-&gt;get_var(<br \/>    \"SELECT COUNT(*) FROM {$wpdb-&gt;posts} p<br \/>     WHERE {$status_condition} {$post_type_condition}<br \/>       AND (<br \/>            p.post_content LIKE '%&#091;embedpress %' OR<br \/>            p.post_content LIKE '%&#091;embedpress]%' OR<br \/>            p.post_content LIKE '%&#091;embedpress_pdf %' OR<br \/>            p.post_content LIKE '%&#091;embedpress_document %' OR<br \/>            p.post_content LIKE '%&#091;embedpress_calendar %'<br \/>       )\"<br \/>);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">&#8230;which generates the following SQL query:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT COUNT(*)<br \/>FROM wp_posts p<br \/>WHERE p.post_status IN ('publish','draft','private','future')<br \/>AND p.post_type IN ('post','page','product','event','portfolio')<br \/>AND (<br \/>  p.post_content LIKE '%&#091;embedpress %' OR<br \/>  p.post_content LIKE '%&#091;embedpress]%' OR<br \/>  p.post_content LIKE '%&#091;embedpress_pdf %' OR<br \/>  p.post_content LIKE '%&#091;embedpress_document %' OR<br \/>  p.post_content LIKE '%&#091;embedpress_calendar %'<br \/>)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Because of the five <code>LIKE '%\u2026%<\/code>&#8216; conditions on post_content, the database cannot make effective use of a normal index; as a result, the query essentially scans through very large portions of <code>wp_posts<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This SQL query takes about 1 minute to run in our WordPress installation (with &gt; 100k posts), which is far too long and needs to be fixed urgently.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Best regards,<br \/>Ben<\/p>\n","protected":false},"template":"","class_list":["post-19017303","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19017303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19017303\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=19017303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}