1👍
As long as you have an index on your type
column and filter on that, it will be about the same speed. When your table gets really big, just shard on the type
column and it will be the same performance as doing multiple tables but your app will just see one big table.
1👍
One “Table” will be better for search purposes (you can “search” on all of the messages at once.
However, multiple tables may benefit from speed.
Why not use abstracted classes?
class MessageBase(models.Model):
subject = models.CharField(max_length=255)
test = models.TextField()
class ChatMessage(MessageBase):
pass
This will create 2 tables, with the table for ChatMessage just referring directly to the table for MessageBase. This will give you the best of both worlds. “Search” using MessageBase to get messages for anything, but save, and refer to, all other messages using it’s specific model class.
(please note, the python here might be slightly wrong, as it hasn’t been tested, but I’m sure you get the idea!)
- [Answered ]-Can't assign correct object instance to ForeignKey field
- [Answered ]-Attribute Error when writing a captcha decorator
- [Answered ]-Django 'OneToOneField' object has no attribute 'id'