0
0
Wordpressframework~10 mins

Database optimization in Wordpress - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to optimize a WordPress database by cleaning up post revisions.

Wordpress
DELETE FROM wp_posts WHERE post_type = '[1]';
Drag options to blanks, or click blank then click option'
Arevision
Bpage
Cattachment
Dnav_menu_item
Attempts:
3 left
💡 Hint
Common Mistakes
Deleting 'page' post_type instead of 'revision'.
Trying to delete 'attachment' which stores media files.
2fill in blank
medium

Complete the code to add an index to the wp_postmeta table for faster queries.

Wordpress
ALTER TABLE wp_postmeta ADD INDEX [1] (meta_key);
Drag options to blanks, or click blank then click option'
Aidx_meta_key
Bmeta_index
Cindex_meta
Dkey_index
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid index names that don't follow conventions.
Not adding an index at all.
3fill in blank
hard

Fix the error in the SQL query to optimize the wp_options table by removing expired transients.

Wordpress
DELETE FROM wp_options WHERE option_name LIKE [1] AND option_value < UNIX_TIMESTAMP();
Drag options to blanks, or click blank then click option'
A'transient_%'
B'_transient_timeout_%'
C'_transient_%'
D'timeout_transient_%'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '_transient_%' which matches transient data, not timeouts.
Using wrong wildcard patterns.
4fill in blank
hard

Fill both blanks to create a query that optimizes the wp_comments table by removing spam and trash comments.

Wordpress
DELETE FROM wp_comments WHERE comment_approved [1] 'spam' OR comment_approved [2] 'trash';
Drag options to blanks, or click blank then click option'
A=
B!=
CLIKE
DNOT LIKE
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' which would delete non-spam comments.
Using LIKE without wildcards.
5fill in blank
hard

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'.

Wordpress
SELECT [1], [2] FROM wp_posts WHERE post_status = '[3]' AND post_type = 'post';
Drag options to blanks, or click blank then click option'
AID
Bpost_title
Cpublish
Ddraft
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'draft' instead of 'publish' for post_status.
Selecting wrong columns.