[wp-trac] [WordPress Trac] #44523: Huge hemory consumption in get_comments()
WordPress Trac
noreply at wordpress.org
Thu Jul 5 14:52:41 UTC 2018
#44523: Huge hemory consumption in get_comments()
--------------------------+--------------------------
Reporter: vijantis | Owner: (none)
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Comments | Version: 4.9.6
Severity: normal | Resolution: invalid
Keywords: | Focuses: performance
--------------------------+--------------------------
Changes (by swissspidy):
* status: new => closed
* resolution: => invalid
* severity: major => normal
* milestone: Awaiting Review =>
Comment:
Hi there and welcome to WordPress Trac!
As far as I can see this is not an issue with WordPress, but your
implementation.
In your `et_comment_count()` function (which is part of your theme, not
WordPress) you're loading **all comments** into memory by using
`get_comments()`. Of course that leads to high memory consumption.
WordPress already offers `wp_count_comments()` and `get_comment_count()`
to get the comment count.
If you really need the comment count per comment type, I suggest you to
copy and adapt these functions, including the caching part.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44523#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list