Skip to content

Commit

Permalink
fix: unused order (#1590)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aeneasr authored Oct 10, 2024
1 parent 8609d96 commit 47548c0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/persistence/sql/relationtuples.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion internal/persistence/sql/traverser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)...,
Expand Down

0 comments on commit 47548c0

Please sign in to comment.