[wp-trac] [WordPress Trac] #39603: The more posts with similar names you have, the slower you save the next one
WordPress Trac
noreply at wordpress.org
Mon Jan 16 14:51:15 UTC 2017
#39603: The more posts with similar names you have, the slower you save the next
one
-------------------------------+-----------------------------
Reporter: bisyarin | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: 4.7.1
Severity: normal | Keywords:
Focuses: performance |
-------------------------------+-----------------------------
Hello, developers! Thank you for your work on Wordpress!
While using Flamingo for saving Contact Form 7 submissions, I encountered
a huge slowdown after more than 11 000 submissions had been saved. I
thought it was a Flamingo problem, but it appears that all autogenerated
post-types in Wordpress can cause this problem.
Contact Form 7 saves submissions as posts with 'flamingo_inbound' type,
and uses 'your-subject' slug when a form doesn't have a subject (which is
my case). So, in all saved form submissions I have 'your-subject, your-
subject-2, ..., your-subject-N' slugs generated by wp_unique_post_slug().
The problem is that for every new 'your-subject-N' slug
wp_unique_post_slug() issues N-1 SELECT queries. In other words,
wp_unique_post_slug() bruteforces a new possible slug, generating a lot of
SQL queries fetching all previously saved similar posts.
You can see it if you run the attached 'generate-many-posts.php' script
from your Wordpress root (more and more queries will be used for saving
every new post).
Also, let me suggest a solution. With the attached patch we don't
bruteforcing the slug suffix. We just get the last appropriate slug,
increment it's suffix, and than use this suffix in a new unique slug.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39603>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list