Complete the code to optimize a WordPress database by cleaning up post revisions.
DELETE FROM wp_posts WHERE post_type = '[1]';
Post revisions are stored as 'revision' post_type. Deleting them helps optimize the database.
Complete the code to add an index to the wp_postmeta table for faster queries.
ALTER TABLE wp_postmeta ADD INDEX [1] (meta_key);Adding an index named 'idx_meta_key' on meta_key speeds up meta queries.
Fix the error in the SQL query to optimize the wp_options table by removing expired transients.
DELETE FROM wp_options WHERE option_name LIKE [1] AND option_value < UNIX_TIMESTAMP();Expired transients are stored with option_name starting '_transient_timeout_'.
Fill both blanks to create a query that optimizes the wp_comments table by removing spam and trash comments.
DELETE FROM wp_comments WHERE comment_approved [1] 'spam' OR comment_approved [2] 'trash';
We delete comments where comment_approved equals 'spam' or 'trash' to clean the table.
Fill all three blanks to write a query that selects post IDs and titles from wp_posts where the post status is 'publish' and the post type is 'post'.
SELECT [1], [2] FROM wp_posts WHERE post_status = '[3]' AND post_type = 'post';
Selecting ID and post_title where post_status is 'publish' returns all published posts.