# Slow WP Performance on WP-Discourse API Endpoint "discourse-comments"

**URL:** https://meta.discourse.org/t/slow-wp-performance-on-wp-discourse-api-endpoint-discourse-comments/128978
**Category:** WordPress
**Created:** [September 19, 2019, 3:35am UTC](https://meta.discourse.org/t/slow-wp-performance-on-wp-discourse-api-endpoint-discourse-comments/128978 "2019-09-19T03:35:17Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![MiggityMac](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miggitymac/32/156658_2.png) [@MiggityMac](https://meta.discourse.org/u/MiggityMac)
#### Post date: [September 19, 2019, 3:35am UTC](https://meta.discourse.org/t/slow-wp-performance-on-wp-discourse-api-endpoint-discourse-comments/128978/1 "2019-09-19T03:35:18Z")

</div>

Hello, All! My first post here.

I am currently working on integrating a 10+ old WP site with Discourse. I have gone to great lengths to ensure that the WP instance is clean and running well with 10 years of data. After installing the WP-Discourse plugin and getting things setup (properly, I hope), the server kept getting slogged. It is hosted on Cloudways, so I asked those engineers if I was missing anything.

They responded that `/wp-json/wp-discourse/v1/discourse-comments?post_id=undefined` was causing a huge performance hit. I’m not sure exactly why post\_id’s would be undefined.

The following picture is a list of url requests within a 24 hour period.

 ![image](https://global.discourse-cdn.com/meta/original/3X/0/2/02ed57d1f7e6d7c1854c6daac0aa18913e27864d.png)

Any thoughts on how I can fix this error? I have searched a lot for a good answer to this. Just making sure I get some insight before deep diving into the nuances of the code.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [September 23, 2019, 4:48pm UTC](https://meta.discourse.org/t/slow-wp-performance-on-wp-discourse-api-endpoint-discourse-comments/128978/2 "2019-09-23T16:48:19Z")

</div>

Sorry about the delayed response to this - I’ve been on holidays.

The route that is getting hit at `/wp-json/wp-discourse/v1/discourse-comments` is only available when the Load Comments With Ajax option is enabled. That option is found on the [WP Discourse](https://github.com/discourse/wp-discourse) Commenting settings tab. Can you try disabling that setting?

---

<div class="post-metadata">

### Author: ![MiggityMac](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miggitymac/32/156658_2.png) [@MiggityMac](https://meta.discourse.org/u/MiggityMac)
#### Post date: [September 23, 2019, 5:21pm UTC](https://meta.discourse.org/t/slow-wp-performance-on-wp-discourse-api-endpoint-discourse-comments/128978/3 "2019-09-23T17:21:04Z")

</div>

No worries, @simon - I hope your travels went well!

I’ll disable that setting this evening and post back with results soon!

Thank you!

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [September 23, 2019, 8:07pm UTC](https://meta.discourse.org/t/slow-wp-performance-on-wp-discourse-api-endpoint-discourse-comments/128978/4 "2019-09-23T20:07:03Z")

</div>

Disabling that setting should take care of the issue with requests being made to `/wp-json/wp-discourse/v1/discourse-comments`. Let me know if it doesn’t.

I’m unsure why requests to that route were being sent with the `post_id=undefined` parameter. The request should be using the `id` of the current post. If the `post_id` parameter is set to `undefined` then the function that handles that route will return an empty string. Enabling the Load Comments With Ajax option will result in more requests being made to your server than if the option is not enabled, so unless you are running into issues with comments not being updated due to caching, it is best to leave that option disabled.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [November 21, 2019, 2:27am UTC](https://meta.discourse.org/t/slow-wp-performance-on-wp-discourse-api-endpoint-discourse-comments/128978/5 "2019-11-21T02:27:26Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
