Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My opinion is that today they are <strong>not reason to <a href="http://en.wikipedia.org/wiki/Denormalization" rel="nofollow">denormalize database</a></strong> in this way to improve performance. Indexes or <strong>partitioning + indexes should be enought</strong>.</p> <p>Also, in case that, for semantic reasons, you prefer have <strong>two tables (models)</strong> like: Chat and ChatHistory (or ChatCurrent and ChatActive) as you say and manage it with django, I thing that the right way to keep consistence is to <strong>create ToArchive() method in ChatCurrent</strong>. This method will move chat entries to historical chat model. You can perform this operation in <strong>background mode</strong>, then you can thread the swap in a <a href="http://celeryproject.org/" rel="nofollow">celery</a> process, in this way online users avoid wait for request. Into celery process the fastest method to copy data is a <strong><a href="https://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly" rel="nofollow">raw sql</a></strong>. Remember that you can encapsulate sql into a <strong>stored procedure</strong>.</p> <p><strong>Edited to include reply to your comment</strong></p> <p>You can perform ChatCurrent.ToArchive() in ChatCurrent.save() method:</p> <pre><code>class ChatCurrent(model.Model): closed=models.BooleanField() def save(self, *args, **kwargs): super(Model, self).save(*args, **kwargs) if self.closed: self.ToArchive() def ToArchive(self): from django.db import connection, transaction cursor = connection.cursor() cursor.execute("insert into blah blah") transaction.commit_unless_managed() #self.delete() #if needed (perhaps deleted on raw sql) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload