mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Refs #28459 -- Improved performance of time difference expressions on MySQL.
This commit is contained in:
parent
75527c0f83
commit
ba4a986240
1 changed files with 2 additions and 2 deletions
|
@ -263,8 +263,8 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|||
rhs_sql, rhs_params = rhs
|
||||
if internal_type == 'TimeField':
|
||||
return (
|
||||
"((TIME_TO_SEC(%(lhs)s) * POW(10, 6) + MICROSECOND(%(lhs)s)) -"
|
||||
" (TIME_TO_SEC(%(rhs)s) * POW(10, 6) + MICROSECOND(%(rhs)s)))"
|
||||
"((TIME_TO_SEC(%(lhs)s) * 1000000 + MICROSECOND(%(lhs)s)) -"
|
||||
" (TIME_TO_SEC(%(rhs)s) * 1000000 + MICROSECOND(%(rhs)s)))"
|
||||
) % {'lhs': lhs_sql, 'rhs': rhs_sql}, lhs_params * 2 + rhs_params * 2
|
||||
else:
|
||||
return "TIMESTAMPDIFF(MICROSECOND, %s, %s)" % (rhs_sql, lhs_sql), rhs_params + lhs_params
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue