Changes between Version 5 and Version 6 of Ticket #25470
- Timestamp:
- Sep 26, 2015, 9:33:45 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #25470 – Description
v5 v6 1 I posted a question at http://stackoverflow.com/questions/32795047/have-a-perforamance-issue-of-query-date-object-using-django-queryset2 3 1 I'm using django 1.8.4 writing a webapp. The backend uses MySQL 5.6 (MyISAM). Recently the number of table records reaches 1 million, it will take 1-1.5 seconds to query all distinct record dates. But using MySQL client, it takes less than 0.001 second. 4 2 … … 19 17 }}} 20 18 21 I noticed that the second query did a type cast. The cast is not a necessary step. It slows down when the amount of records is huge. I pretty sure this is the root cause of the slow. 22 23 The table is created by django. The field is exactly `DATE` field. I'd like to know, why django cast DATE to DATETIME. Is it a bug? 19 As you can see, the query did possibly an unnecessary type cast. The performance impact is scaled to the amount of records. The table field is exactly `DATE` type. I don't know, if there is some reason for the type casting. 24 20 25 21 Currently, I use a workaround: 26 22 {{{ 27 db_dates = [dt['date'] for dt in Model1.objects.order_by('date').values('date').distinct()]23 db_dates = Model1.objects.values_list('date', flat=True).distinct() 28 24 }}} 25 26 I posted a question at [http://stackoverflow.com/questions/32795047/have-a-perforamance-issue-of-query-date-object-using-django-queryset StackOverflow].