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.
**Mysql version = 5.6.39**
**No of rows in table = 5M**
--
Ticket URL: <https://code.djangoproject.com/ticket/30143>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> {{{
> class Model:
> a = models.CharField(max_length=100)
> b = models.CharField(max_length=100)
> c = models.CharField(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.
>
> **Mysql version = 5.6.39**
> **No of rows in table = 5M**
New description:
{{{
class Model:
a = models.CharField(max_length=100)
b = models.CharField(max_length=100)
c = models.CharField(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**
--
--
Ticket URL: <https://code.djangoproject.com/ticket/30143#comment:1>
Old description:
> {{{
> class Model:
> a = models.CharField(max_length=100)
> b = models.CharField(max_length=100)
> c = models.CharField(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**
New description:
{{{
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**
--
--
Ticket URL: <https://code.djangoproject.com/ticket/30143#comment:2>
* status: new => closed
* resolution: => invalid
--
Ticket URL: <https://code.djangoproject.com/ticket/30143#comment:3>