Simplify CleanOldUserSessions' query

No need for a subquery, filtering on `created_at` directly is enough.
This commit is contained in:
jvoisin 2024-02-25 16:04:46 +01:00 committed by Frédéric Guillot
parent 0adac5c6f7
commit 04916a57d2
2 changed files with 2 additions and 2 deletions

View file

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

View file

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