On Tue, Feb 1, 2011 at 2:18 PM, Karen McNeil <karenlmcn...@gmail.com> wrote: > Thank you for your responses. > > I think you're right that calculating the wordcount could be the > problem. I also have another method that displays the authors, so that > I can see the author(s) in the admin list, even though it's a > ManyToMany relationship. I would imagine that that's part of the > problem too, since it has to make a separate db query for each item it > displays -- can I fix that using post_save as well? > > ~Karen >
If your documents are always edited through django's admin interface, you could calculate the number of words at save time, and store it as an attribute on the model. That way, you do not have to be continually re-calculating it for documents. There are some gotchas with this method, updates that do not go through the model instance would not be updated (eg, smth like "Document.objects.filter(id__in=id_list).update(text='')" does not create instances for each changed object, and so the overridden save() method is not called, and the attribute is not updated.) Another way that may improve speed would be to disassociate the large documents from the metadata describing those documents. This would speed up queries that deal solely with the metadata, whilst still allowing a simple way of accessing that data. Eg, define a DocumentImplementation model, that holds the content of a document, give Document a foreign key to this new model. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.