diff --git a/internal/storage/postgres/relationshipReader.go b/internal/storage/postgres/relationshipReader.go index 646444673..847061496 100644 --- a/internal/storage/postgres/relationshipReader.go +++ b/internal/storage/postgres/relationshipReader.go @@ -300,7 +300,7 @@ func (r *RelationshipReader) HeadSnapshot(ctx context.Context, tenantID string) var xid types.XID8 // Build the query to find the highest transaction ID associated with the tenant. - builder := r.database.Builder.Select("MAX(id)").From(TransactionsTable).Where(squirrel.Eq{"tenant_id": tenantID}) + builder := r.database.Builder.Select("id").From(TransactionsTable).Where(squirrel.Eq{"tenant_id": tenantID}).OrderBy("id DESC").Limit(1) query, args, err := builder.ToSql() if err != nil { span.RecordError(err)