[Django] #30143: Django query abrupt behaviour

1 view
Skip to first unread message

Django

unread,
Jan 30, 2019, 2:36:21 AM1/30/19
to django-...@googlegroups.com
#30143: Django query abrupt behaviour
-------------------------------------+-------------------------------------
Reporter: Shashank | Owner: nobody
Parekh |
Type: Bug | Status: new
Component: Database | Version: 2.1
layer (models, ORM) |
Severity: Release | Keywords:
blocker |
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
{{{
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**

--
Ticket URL: <https://code.djangoproject.com/ticket/30143>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 30, 2019, 2:55:48 AM1/30/19
to django-...@googlegroups.com
#30143: Django query abrupt behaviour
-------------------------------------+-------------------------------------
Reporter: Shashank Parekh | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Shashank Parekh:

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>

Django

unread,
Jan 30, 2019, 3:07:20 AM1/30/19
to django-...@googlegroups.com
#30143: Django query abrupt behaviour
-------------------------------------+-------------------------------------
Reporter: Shashank Parekh | Owner: nobody
Type: Bug | Status: new

Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Shashank Parekh:

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>

Django

unread,
Jan 30, 2019, 5:14:42 AM1/30/19
to django-...@googlegroups.com
#30143: Django query abrupt behaviour
-------------------------------------+-------------------------------------
Reporter: Shashank Parekh | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Release blocker | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Shashank Parekh):

* status: new => closed
* resolution: => invalid


--
Ticket URL: <https://code.djangoproject.com/ticket/30143#comment:3>

Reply all
Reply to author
Forward
0 new messages