Refs #28459 -- Improved performance of time difference expressions on MySQL.

This commit is contained in:
Sergey Fedoseev 2018-03-01 14:39:17 +05:00
parent 75527c0f83
commit ba4a986240
1 changed files with 2 additions and 2 deletions

View File

@ -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