diff --git a/internal/persistence/sql/relationtuples.go b/internal/persistence/sql/relationtuples.go index f36103f57..9d82bee31 100644 --- a/internal/persistence/sql/relationtuples.go +++ b/internal/persistence/sql/relationtuples.go @@ -214,7 +214,7 @@ func (p *Persister) GetRelationTuples(ctx context.Context, query *relationtuple. } sqlQuery := p.queryWithNetwork(ctx). - Order("shard_id, nid"). + Order("shard_id"). Where("shard_id > ?", pagination.LastID). Limit(pagination.PerPage + 1) diff --git a/internal/persistence/sql/traverser.go b/internal/persistence/sql/traverser.go index 542e6f2ff..33af2402e 100644 --- a/internal/persistence/sql/traverser.go +++ b/internal/persistence/sql/traverser.go @@ -85,7 +85,7 @@ WHERE current.nid = ? AND current.object = ? AND current.relation = ? AND current.subject_id IS NULL -ORDER BY current.nid, current.shard_id +ORDER BY current.shard_id LIMIT ? `, targetSubjectSQL), append(targetSubjectArgs, t.p.NetworkID(ctx), shardID, start.Namespace, start.Object, start.Relation, limit)...,