I've got a pretty straight forward question. When does it become too much data to use add_option, update_option, etc, and instead use a custom DB table?

For example, if a plugin stores thousands and thousands of characters of data using add_option, etc, is there a maximum it can handle before it starts to create problems?

A plugin of mine used to create its own DB table, but it created a lot of issues in which some users setups wouldn't work (especially on Microsoft based hosting servers), and many more users felt the need to contact me and advise me on using add_option instead. I followed their advise, and now the plugin uses these functions.

However, I've come a long way in my coding abilities since then and in-turn have started redesigning the plugin. It now has much, much more data to be stored using add_option. Even up to over 10000+ characters worth, and I'm beginning to wonder if it will cause any problems.


For the record, I will never encourage developers to use custom database tables. Yes, they're easy to use, but you lose 100% of the data abstraction provided by WordPress.

add_option()/update_option()/get_option() are basic key-value functions. They store data in a MySQL LONGTEXT field. LONGTEXT can store over 4 million characters ... so a 10000+ character option is definitely possible.


Sometimes custom database tables are unavoidable. If you have a data type (eg "jobs") with many different properties, and you anticipate that you'll need to do complicated filters on that data (eg, "show me all the jobs in Maryland that require <5 years experience and pay more than $80K and involve either programming or design skills"), it's going to be nearly impossible to scale to millions of rows without a properly indexable table.

So the answer to your question really depends on the kind of data you're storing. The options table works fine for configuration-type data (which is only read in a single way), but is not great for data that needs to be queried in many different ways.

Depending on the kind of data, you might consider registering a custom post type. Here is a nice primer: http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress. CPTs work really nicely to store pretty large amounts of data that is more-or-less post-like in structure (not too many different kinds of metadata, doesn't require item-to-item relationship logic). This is in some ways the best of both worlds: you get the ability to do pretty sophisticated queries like you'd do on a custom table (via WP_Query), while getting to take advantage of WP's "data abstraction", as @EAMann suggests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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