Skip to content

Commit 47548c0

Browse files
authored
fix: unused order (#1590)
We filter for `nid = ?` so there is no point in ordering by nid. Column `shard_id` is the prefix (`CONSTRAINT keto_relation_tuples_uuid_pkey PRIMARY KEY (shard_id ASC, nid ASC)`) so it should not impact the query planner.
1 parent 8609d96 commit 47548c0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

internal/persistence/sql/relationtuples.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (p *Persister) GetRelationTuples(ctx context.Context, query *relationtuple.
214214
}
215215

216216
sqlQuery := p.queryWithNetwork(ctx).
217-
Order("shard_id, nid").
217+
Order("shard_id").
218218
Where("shard_id > ?", pagination.LastID).
219219
Limit(pagination.PerPage + 1)
220220

internal/persistence/sql/traverser.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ WHERE current.nid = ? AND
8585
current.object = ? AND
8686
current.relation = ? AND
8787
current.subject_id IS NULL
88-
ORDER BY current.nid, current.shard_id
88+
ORDER BY current.shard_id
8989
LIMIT ?
9090
`, targetSubjectSQL),
9191
append(targetSubjectArgs, t.p.NetworkID(ctx), shardID, start.Namespace, start.Object, start.Relation, limit)...,

0 commit comments

Comments
 (0)