As we all know, a design pattern that is used frequently in WordPress' DB code is the idea of persisting data for a particular object (blog/post/comment), indexed with a particular name or key.

We see this pattern used in the following standard tables:

  • wp_options
  • wp_commentmeta
  • wp_postmeta

As far as I can tell, the motivation for this design decision was to enable plugin/theme authors to persist data easily (e.g. by using custom fields) without having to modify the database schema. It would seem to me that there are few other advantages to this approach, since it is significantly slower and makes it harder to implement complex queries.

What are the other advantages to this approach, if any?

UPDATE: Reading info on the drawbacks of this approach:

  • I have no idea of database schemas or performance... But, just for the sake of the argument, can you reference your statements? Like in Wikipedia, "citation needed"...
    – brasofilo
    Dec 21, 2012 at 2:20
  • 1
    Options are meant to be key-value pairs, there's nothing wrong there. However in the case of post meta, the answers you linked from stackoverflow are relevant here as well: this is just poor design. Dec 21, 2012 at 4:43
  • Most important failure of WordPress is their database design. Its only useable for hosehold websites. High-performance sites will never use Anti-pattern as database design due to performance issues like BASIC indexing! Jun 9, 2015 at 11:39

1 Answer 1


The ability to store abstract key-value pairs without modifying the database structure is the reason. Without that, WordPress loses much of its flexibility. I can't speak for others, but the single largest reason why I develop atop WordPress is its flexible nature.

To quote one of your links above,

Usually the reasoning behind doing what you are doing is because the domains need to be "user definable". If that is the case then even I am not going to push you towards creating tables on the fly...

While it's true that it forces queries to be more complex, and a little slower, the benefits far outweigh the costs. But, hey, it's all about what you're doing. Don't use a hammer to bang in a screw. If you still want to use WordPress, but need to run complex queries on steady, structured sets of data, check out Pods.

I hope this helps you out!

  • -1. WP actually loses flexibility, just take a look of all the questions here asking solutions for sorting or searching posts by meta values. Also queries are a lot slower because of all the joins you're forced to perform. You didn't mention any definite benefit of using this pattern. Dec 21, 2012 at 4:50
  • 2
    @OneTrickPony First off, thanks for taking the time to explain the downvote. Second, "just take a look of all the questions here asking solutions for ..." is not an argument; you could insert anything at the end of that sentence ;-). I stand behind my argument that the sole benefit is flexibility. If you wanted to store a new option on your site, or a new field associated with users or posts, and you had to modify the structure of the database, it would get out of hand very quickly. But hey, WP is open source, if you can do better, the community welcomes it! Dec 21, 2012 at 5:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.