Opened 6 years ago

Last modified 6 years ago

#30143 closed Bug

Django query abrupt behaviour — at Version 2

Reported by: Shashank Parekh Owned by: nobody
Component: Database layer (models, ORM) Version: 2.1
Severity: Release blocker Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Shashank Parekh)

class Model:
     a = models.CharField(max_length=100)
     b = models.CharField(max_length=100)
     c = models.DateTimeField(max_length=100)


query1 = Models.objects.filter(Q(a__in=['1']) | Q(b__in=['2'])).filter(**{'c__gte': timezone.datetime(2019,1,1), 'c__lte': timezone.datetime(2019,2,1)}).order_by('-c')

query2 = Models.objects.filter(Q(a__in=['1']) | Q(b__in=['2'])).filter(**{'c__gte': timezone.datetime(2019,1,1), 'c__lte': timezone.datetime(2019,2,1)})

query2 is executed perfectly but query1 is timing out.

I did explain on query1 and ran the query(on explain() output) on MySQL directly and it worked absolutely fine.
query1 worked fine in django1.8 but not in django2.1.

Although, If I use query1.iterator() it is working.

Mysql version = 5.6.39
No of rows in table = 5M

Change History (2)

comment:1 by Shashank Parekh, 6 years ago

Description: modified (diff)

comment:2 by Shashank Parekh, 6 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top