On Feb 12, 9:52 am, Tomas Kouba <to...@jikos.cz> wrote: > Dear django users, > > I have a design problem with my model. > I have a class that has one attribute "archived". Records with archived==False > are accessed much more often than archived==True. > The number of records with archived==True is much higher. > > Other attributes (db columns) are the same for both types. > My question is whether: > > 1) I should put this in one table, create index and hope > for database cleverness. > 2) Create Abstract model class, let django make two similar tables and > work with two models in my code. > 3) Any other neat solution in django.
Ain't that bordering on premature optimization ? or do you have a real performance issue, and profiling showed that db was the bottleneck ? Anyway... an index on "archived" may do more harm than good. To be really useful, an index needs to be as discriminating as possible - that is, have has few rows as possible per index value. For the record, the "best" (perfomance wise) indexes are unique indexes - one row per index value. In your case, indexing the "archived" field may only help retrieving unarchived rows *if* they make for less than +/- 10% of the total rows - and even then, this may depends on your DBRMS engine. I guess the "best" tuning here would be doing a db-level horizontal partition: http://en.wikipedia.org/wiki/Partition_(database) http://dev.mysql.com/doc/refman/5.1/en/partitioning.html http://www.postgresql.org/docs/current/interactive/ddl-partitioning.html HTH -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.