On Wednesday, October 2, 2013 1:29:10 PM UTC-4, Zev Benjamin wrote:

> What kind of additional configuration?  One advantage of not specifying 
> the type of the db_index_type field is that you could instantiate an object 
> that encapsulates the configuration.
>

That's true. I am partial to opening up Meta for other reasons, but in this 
case, if you were to have an arbitrary config object that is passed to the 
db backend, then you could specify the App Engine indexes.

App Engine itself creates indexes on each field, by default all fields are 
indexed, so this is something that you have to explicitly turn off. There 
are also composite indexes, which index across many fields, these are 
controlled via a separate App Engine-specific file (so its unrelated to 
this discussion). But on top of all that there's an extension to the app 
engine backend called django-dbindexer that allows you to add more indexes, 
like for case-insensitive queries or contains queries. App Engine can't do 
these things out of the box. Currently, you use another special file for 
these indexes, but it would be nice to have this all configured on the 
field.

--Alex
 

>
> On Wednesday, October 2, 2013 1:19:31 PM UTC-4, Alex Burgel wrote:
>>
>> This is something that I'd also be interested in. For the Google App 
>> Engine backend, you have the ability to create indexes that require more 
>> configuration than just on/off. But I don't think a single additional field 
>> would do the trick for my case.
>>
>> Another option would be to open up the Meta class for custom attributes. 
>> There's a thread which discusses this here:
>>
>> https://groups.google.com/forum/#!topic/django-developers/JEDJYB41LGI
>>
>> The config might look something like this:
>>
>> class Article(db.models):
>>   class Meta:
>>     custom_indexes = {'field1': 'hash', 'field2': 'btree'}
>>  field1 = db.IntegerField()
>>  field2 = db.CharField() 
>>
>> The tradeoff would be that the index would not be specified in the field 
>> description, but it would be close enough. (Currently for the app engine 
>> backend, you specify these in a separate file that the backend looks for.)
>>
>> On Monday, September 23, 2013 10:36:56 AM UTC-4, Zev Benjamin 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 django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
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/6b0ba289-45c7-403f-b6bf-0e646fd139ce%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to