Thanks for the feedback, Michael. On Monday, September 23, 2013 1:06:12 PM UTC-4, Michael Manfre wrote: > > 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. >
The problem is that extensions like django-hstore want to be able to provide indexing like normal fields and the index type in that situation can make a huge performance difference. > 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. > My original reason for not doing it this way was that there might be conflicts between db_index and db_index_type. For example, what should happen if db_index_type is specified, but db_index is False? But I suppose we can make db_index_type override db_index like Django already does for foreign keys. > > 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. > I've created a new version that takes this approach at <https://github.com/zbenjamin/django/compare/index-types>https://github.com/zbenjamin/django/tree/index-types2. What are the next steps if I'd like to submit this upstream? I know the branch needs documentation and tests, but my understanding is that there also must be an accepted Django ticket and I'm a little fuzzy on that process. Thanks, Zev > > Regards, > Michael Manfre > > > > On Mon, Sep 23, 2013 at 10:36 AM, Zev Benjamin > <[email protected]<javascript:> > > 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] <javascript:>. >> To post to this group, send email to >> [email protected]<javascript:> >> . >> 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. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/16b5cdd6-730d-40da-a66a-5bffe363b7b8%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
