Simplify CleanOldUserSessions' query
No need for a subquery, filtering on `created_at` directly is enough.
This commit is contained in:
parent
0adac5c6f7
commit
04916a57d2
2 changed files with 2 additions and 2 deletions
|
@ -128,7 +128,7 @@ func (s *Storage) CleanOldSessions(days int) int64 {
|
|||
DELETE FROM
|
||||
sessions
|
||||
WHERE
|
||||
id IN (SELECT id FROM sessions WHERE created_at < now() - interval '%d days')
|
||||
created_at < now() - interval '%d days'
|
||||
`
|
||||
result, err := s.db.Exec(fmt.Sprintf(query, days))
|
||||
if err != nil {
|
||||
|
|
|
@ -170,7 +170,7 @@ func (s *Storage) CleanOldUserSessions(days int) int64 {
|
|||
DELETE FROM
|
||||
user_sessions
|
||||
WHERE
|
||||
id IN (SELECT id FROM user_sessions WHERE created_at < now() - interval '%d days')
|
||||
created_at < now() - interval '%d days'
|
||||
`
|
||||
result, err := s.db.Exec(fmt.Sprintf(query, days))
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue