Knowledgebase

Useful Queries for WordPress Sites Print

  • databasesphpmyadmin, databases, wordpress, spam, domain, domainrenewal, https, php, performance, troubleshooting
  • 0

Common tasks.

BEFORE ANY OF THESE

Export the affected table.

CHECKING THE SITE URL

SELECT * FROM wp_options WHERE option_name IN ('siteurl','home');

Both should be the https form of your domain.

COUNTING POST REVISIONS

SELECT COUNT(*) FROM wp_posts WHERE post_type = 'revision';

Frequently a surprisingly large number.

FINDING EXPIRED TRANSIENTS

SELECT COUNT(*) FROM wp_options WHERE option_name LIKE '%_transient_%';

These accumulate and are rarely cleared automatically.

FINDING AUTOLOADED DATA

SELECT option_name, LENGTH(option_value) FROM wp_options WHERE autoload = 'yes' ORDER BY LENGTH(option_value) DESC LIMIT 20;

Autoloaded options load on every page. A large one slows the entire site, and this query finds it.

COUNTING SPAM COMMENTS

SELECT COUNT(*) FROM wp_comments WHERE comment_approved = 'spam';

THE TABLE PREFIX

These assume wp_. Check yours in wp-config.php and adjust.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot