Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncached SQL queries on every page load. #17005

Open
2 of 9 tasks
spacedmonkey opened this issue May 8, 2021 · 10 comments
Open
2 of 9 tasks

Uncached SQL queries on every page load. #17005

spacedmonkey opened this issue May 8, 2021 · 10 comments

Comments

@spacedmonkey
Copy link
Contributor

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened.

Using the plugin query monitor, I am seeing raw uncached sql queries run on every page load. See screenshots.

Screenshot 2021-05-08 at 19 44 54

Screenshot 2021-05-08 at 19 47 12

Screenshot 2021-05-08 at 19 47 41

Please describe what you expected to happen and why.

After second page load, these queries should be cached.

How can we reproduce this behavior?

Technical info

  • If relevant, which editor is affected (or editors):
  • Classic Editor
  • Gutenberg
  • Classic Editor plugin
  • Which browser is affected (or browsers):
  • Chrome
  • Firefox
  • Safari
  • Other

Used versions

  • WordPress version: 5.7.1
  • Yoast SEO version: 16.1
  • Gutenberg plugin version:
  • Classic Editor plugin version:
  • Relevant plugins in case of a bug:
  • Tested with theme:
@Djennez
Copy link
Member

Djennez commented May 10, 2021

@spacedmonkey could you elaborate what's wrong in this situation? It's not new behavior (been there since the indexables release in 14.0).

@spacedmonkey
Copy link
Contributor Author

@Djennez I just noticed this. I would say these queries should be cached for performance reasons.

The biggest issue, is if multiple queries. On one page request, I was getting 14 queries. On my homepage, I was getting 128 queries. That is a lot.

Screenshot 2021-05-11 at 16 28 54

Enough to take a database server down a peak request times.

@Djennez
Copy link
Member

Djennez commented Jul 9, 2021

@spacedmonkey can you find why all those posts are individually retrieved from the database on your frontpage? From what I can see, this is behavior that is not present on a default WordPress installation. Also, can you enlighten me on how / what needs to be cached if every one of these queries is retrieving different data, I think I am missing that context?

@Djennez
Copy link
Member

Djennez commented Aug 3, 2021

Is there any more information available about this issue? As stated before, we can't reproduce the large amount of individual indexable calls on empty WordPress installations, so we expect some sort of conflict. The issue we see here is just the amount of calls, not the fact they aren't cached. Because they're rather fast.

@Djennez
Copy link
Member

Djennez commented Aug 24, 2021

I'm going to close this due to inactivity without it having sufficient information. If additional information is provided, we'll look into reopening the issue.

@Djennez Djennez closed this as completed Aug 24, 2021
@jdevalk
Copy link
Contributor

jdevalk commented Mar 28, 2022

@Djennez Jonny Harris (@spacedmonkey, the OP of this issue) was asking about it, so I've reopened it for him.

@jdevalk jdevalk reopened this Mar 28, 2022
@spacedmonkey
Copy link
Contributor Author

Thank you for re-opening.

Looking into this issue again, while reviewing new relic logs. I see 3 uncaching MySQL on my pages. See a screenshot from query monitor from my about us page, spacedmonkey.com/about.

Screenshot 2022-03-28 at 11 14 59

These queries are coming from this method. The query seem pretty simple, querying WP SEO's custom table, by object id and type. So the query runs quickly. But simple query like this should be cached. Query by id and type, makes a cache key generation simple.

$cache = wp_cache_get( "$id_$type", 'wp-seo' );

Cache invalidation should be simple, only updating / deleting key when that object is updated. Otherwise, that cache should be valid forever.

I know it is simple query, but for sites under heavily load or under a DDOS attack, 3 queries a page should take the database server and website down. Will to support on this ticket and provide as much information, testing and code review as needed.

@spacedmonkey
Copy link
Contributor Author

Still awaiting a response on this one.

@carl-alberto
Copy link

+1 on this issue
Screen Shot 2022-10-25 at 11 20 44 PM

@spacedmonkey
Copy link
Contributor Author

@schlessera Is there any chance someone could look into this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants