I've got a model "Messages" that we use to keep messages through the site. They are messages in discussions, private messages and most likely chat. They all are saved in 1 table. I question if it will likely be faster basically spread messages among several models and tables. 1 for chat, one for discussions and so forth.
So must i keep all messages in 1 table/model or create several identical models/tables?
One "Table" will improve for search reasons (you are able to "search" on all the messages at the same time.
However, multiple tables will benefit from speed.
Why don't you use abstracted classes?
class MessageBase(models.Model): subject = models.CharField(max_length=255) test = models.TextField() class ChatMessage(MessageBase): pass
This can create 2 tables, using the table for ChatMessage just mentioning straight to the table for MessageBase. This provides you with the very best of both mobile phone industry's. "Search" using MessageBase to obtain messages for anything, but save, and make reference to, other messages using it's specific model class.
(please be aware, the python here may be slightly wrong, because it has not been examined, but I am sure you get the drift!)
As lengthy as you've a catalog in your
type column and filter on that, it will likely be comparable speed. Whenever your table will get really large, just shard around the
type column and it'll function as the same performance as doing multiple tables however your application will just see one large table.