I'm developing a system that will have around 2k users and they will be communicating with an internal live chatting system.

Now I'm wondering if it's a good choice to store messages as custom post type? Or it's better to use custom table for them?

2 Answers 2


As far as I can see, the main problem you might have to deal with is having to store a fairly large amount of chat messages.

So to avoid making WP core functionalities querying post and postmeta from large amount of rows generated by your single functionality, it seems obvious to me you'd better create a custom table.

I believe this would also offer to you the possibility to optimize your table's structure for your specific usage which would result in faster queries.

At this time, WP postmeta queries get very slow generally speaking, when they have to deal with a large amount of rows. Look at the problem WooCommerce actually has when dealing with over 100k products which they store as post and postmeta. They're on the way of fixing this by migrating all the products inside custom tables...

  • If you don't need the meta or terms there are parameters to wp_query to suppress those parts of the query. I don't know what impact that would have though. Oct 2, 2016 at 21:46

I would definitely not do that... In my opinion, the way to go here is to combine JavaScript/JSON and classic MySQL data storage. It seems to me that storing every direct message directly into a DB would use way too much resources, and would probably get very slow when you have a large number of them. Also, keep in mind that it's a security issue to have all messages stored in one table, they should be associated with users.

  • I don't understand what you mean about the security implications. Are you saying you think that having multiple tables would be more secure? How?
    – alnorth29
    Oct 7, 2016 at 11:07
  • Theoretically, if your user has access to the table where all the other chat messages from other users are stored, he could get access to all the other chat messages on your system. It makes more sense to store this as user-specific data.
    – Pim
    Oct 9, 2016 at 21:11

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.