Skip to content
hostcomplex

WordPress Database Tables

Maarten Soetens 2 min read

What WordPress Keeps in Its Database

The WordPress database tables are the structured storage where a site keeps its content and most of its settings. Posts, page text, user accounts and comments live in the database, while code and uploaded files live in the file system. Each table holds one kind of record, and by default the table names begin with the prefix wp_.

When a visitor requests a page, WordPress reads several tables: it finds the content, reads the related details and settings, and passes the results to the theme to build the page. The general architecture is explained in the how a CMS works article.

The Core Tables and What They Hold

  • wp_posts stores posts, pages, media entries, revisions and custom content types.
  • wp_postmeta stores extra details for posts as key and value pairs, including custom field data.
  • wp_users and wp_usermeta store account records and extra profile data such as roles and preferences.
  • wp_terms, wp_term_taxonomy and wp_term_relationships store categories, tags and the links between them and content.
  • wp_options stores site-wide settings, including many written by themes and plugins.
  • wp_comments and wp_commentmeta store comments and their extra details.

Why Autoloaded Options and Leftover Data Matter

Each row in wp_options has an autoload setting. Entries marked to autoload are loaded on every page request, so a large amount of autoloaded data slows every visit, even when a particular page does not need it.

Plugins often add rows or tables when they are installed. Some remove their data when deleted and others leave it behind. Over time, unused rows accumulate, which increases database size and the work needed to read it. This is one reason the number of plugins matters, as explained in the plugin bloat article.

For example, a site that used a large plugin years ago may still hold that plugin’s settings in wp_options. The data is invisible in the admin area, yet if it is autoloaded, it is still read on every request.

Frequently asked questions

Can I edit the WordPress database directly?

You can, but direct edits are risky. A wrong change to wp_options or wp_posts can break a site, and WordPress does not check manual edits. Most changes are better made through the admin area, the theme or a plugin, and any direct change should follow a verified backup.

Does the database store my images?

The database stores a record for each image, including its title, alt text and file path. The image files themselves are kept in the wp-content/uploads folder, described in the file structure article. Both parts are needed, so a backup must include the database and the files together.

  • Two-Factor Authentication

    Two factor authentication hosting adds a second check to control panel, domain and CMS logins. Learn which methods are strongest and why 2FA helps.

  • What Is an A Record?

    What is an A record? Learn how this DNS record maps a hostname to an IPv4 address, why domains use several A records and the root and www pattern.

  • Billing and Automation Platforms

    What is WHMCS? Learn how this commercial billing and automation platform helps hosts sell plans, collect payments and create accounts automatically.