Is it bad practice to create own table for a plugin?

Posted by Prem Tiwari | Updated on

I rarely disagree with otherwise knowledgeable users, but in this case I can’t help it. In my opinion calling the usage of non-core database tables bad practice per se is just simply wrong.

The choice of whether to go with core tables or add your own depends on several factors.

A query’s execution time depends on the size of the table. Hence, if you’re planning on storing significant amounts of data, a separate table catering to just this one type of specific data set will inevitably be the more efficient solution.

If you store a lot of regular posts or CPTs alongside these specific data sets, wp_posts as well as wp_postmeta can grow quickly.

For me, this choice ultimately depends on how “posty” the data is. Should it support an author, comments, revisions, excerpts or the like? If so, I’ll go with CPTs and/or core functionality. If not, I’ll go with separate tables for the sake of resource usage and efficiency.

If Eugene’s notion were correct, none of the existing well-written plugins would add their own tables, which fortunately is not the case.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers