My personal opinion is that If you need to get in to this much detail about your indices, you're probably better off tweaking things directly against the database and not specifying them in the model. With that said, here are a few suggestions for your proof of concept.
Don't piggyback db_index. It would be cleaner to add another argument "db_index_type" that can hold whatever values the database backend is willing to support. There should not be any backend specific logic outside of the database backends and test suite. I'd recommend altering your validation.py changes to check a new DatabaseFeature supports_db_index_types and adding a method to BaseDatabaseCreation that can validate the db_index_type. db_index_type doesn't necessarily need to be a string. Better to let the database backends decide whether it is best to have db_index_type represented as a string, int, or object. Regards, Michael Manfre On Mon, Sep 23, 2013 at 10:36 AM, Zev Benjamin <[email protected] > wrote: > Hi, > > I'd like to be able to specify what kind of index the database should use > for a particular field. I have a proof of concept branch that works with > PostgreSQL at https://github.com/zbenjamin/django/compare/index-types, > but I'd like to solicit opinions on whether there's a better way of doing > it. The way it works in my branch is that you specify the index type by > making the Field db_index argument a string containing the name of the > index type you'd like to use. Specifying db_index=True uses the default > index type. > > Example usage: > > class IndexTest(models.Model): > unindexed = models.IntegerField(db_index=False) > default_indexed = models.IntegerField(db_index=True) > btree_indexed = models.IntegerField(db_index="btree") > hash_indexed = models.IntegerField(db_index="hash") > > > > Zev > > -- > You received this message because you are subscribed to the Google Groups > "Django developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/django-developers. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. For more options, visit https://groups.google.com/groups/opt_out.
