I have a string index problem for my query.
I have a model like this:
from django.db import models  
class Record(models.Model):
    user = models.ForeignKey(User, db_index=True, related_name='records')
    action = models.ForeignKey(Action, db_index=True)
    time = models.DateTimeField(db_index=True, default=timezone.now)
    class Meta:
        index_together = (
            ('user', 'time'),
            ('action', 'user', 'time'),
        )
As you can see, there are two custom indexes for this model.
If I want to get all records related to a particular user, filtered time, I use this query: user.records.filter(time__gt=some_moment). It works fine and uses the first user index (according to
source
share