[wp-trac] [WordPress Trac] #58368: WordPress dashboard is very slow when there are many comments (and the database isn't great)
WordPress Trac
noreply at wordpress.org
Tue Jun 20 08:08:48 UTC 2023
#58368: WordPress dashboard is very slow when there are many comments (and the
database isn't great)
--------------------------------------+--------------------------
Reporter: Guss77 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.3
Component: Comments | Version: 6.2.2
Severity: minor | Resolution:
Keywords: has-patch has-unit-tests | Focuses: performance
--------------------------------------+--------------------------
Comment (by FolioVision):
Replying to [comment:31 peterwilsoncc]:
> Good catch, I've added it in to the dropdown in my PR.
Thank you for the follow up.
I tested the new version of your branch: https://github.com/peterwilsoncc
/wordpress-develop/tree/try/58368-comment-count-no-orderby
With standard WordPress the query responsible for the comment type drop
down:
{{{
SELECT wp_5_comments.comment_ID
FROM wp_5_comments
WHERE ( ( comment_approved = '0'
OR comment_approved = '1' ) )
AND comment_type IN ('pingback', 'trackback')
ORDER BY wp_5_comments.comment_date_gmt DESC
LIMIT 0,1
}}}
Would take 7.28 seconds on average.
With the new improved code the query would look like this:
{{{
SELECT wp_5_comments.comment_ID
FROM wp_5_comments
WHERE ( ( comment_approved = '0'
OR comment_approved = '1' ) )
AND comment_type IN ('pingback', 'trackback')
LIMIT 0,1
}}}
But strangely it would take 8.68 seconds.
As I explained in our ticket the `comment_type` **index** is what really
helps: #58488
With that index the query would take 0.3 miliseconds on average.
Each test was repeated 4 times and I would go from the original code to
the new branch and then back and run more tests to ensure the numbers are
not affected by something else.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58368#comment:32>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list