From 0f79a081a26c6016b03bcb197a84f2650d5bbce3 Mon Sep 17 00:00:00 2001 From: Jo Asplin Date: Thu, 26 Sep 2024 13:49:31 +0200 Subject: [PATCH] Simplified SQL statement --- .../datastore/storagebackend/postgresql/postgresql.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/datastore/datastore/storagebackend/postgresql/postgresql.go b/datastore/datastore/storagebackend/postgresql/postgresql.go index a99cdeba..b44c2ab2 100644 --- a/datastore/datastore/storagebackend/postgresql/postgresql.go +++ b/datastore/datastore/storagebackend/postgresql/postgresql.go @@ -369,13 +369,11 @@ func cleanup(db *sql.DB) error { rmUnrefRows := func(tableName, fkName string) error { cmd := fmt.Sprintf(` - DELETE FROM %s - WHERE id in ( - SELECT id FROM %s t WHERE NOT EXISTS ( - SELECT FROM observation obs WHERE %s = t.id - ) + DELETE FROM %s t + WHERE NOT EXISTS ( + SELECT FROM observation WHERE %s = t.id ) - `, tableName, tableName, fkName) + `, tableName, fkName) _, err = db.Exec(cmd) if err != nil {