From 4b579d4c9bf3f84980c4b16ef8ad8d1f97c93892 Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 23 Oct 2023 01:56:15 +0200 Subject: [PATCH] Fix: get last diff request performance --- internal/postgres/rollback.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/postgres/rollback.go b/internal/postgres/rollback.go index 43d437f42..75f3505a3 100644 --- a/internal/postgres/rollback.go +++ b/internal/postgres/rollback.go @@ -73,7 +73,7 @@ func (r Rollback) LastDiff(ctx context.Context, ptr int64, keyHash string, skipR query.Where("value is not null") } - err = query.Order("id desc").Limit(1).Scan(ctx) + err = query.OrderExpr("timestamp desc, id desc").Limit(1).Scan(ctx) return }