willthornton.
10/09/2023, 12:48 PMvroldanbet
10/09/2023, 12:59 PM--explain
to get a better understanding on the path traversed on the permission check used for LookupResources
. Typically what we see is contention over connection pools - it's not so much a CPU/Memory problem on the SpiceDB side. You want to understand where is time being spent down to the SQL query.
LookupResources
can put a bunch of load over your database cluster. I suggest turning on Performance Insights for RDS to get a sense spikes are happening and queries are getting queued: https://aws.amazon.com/rds/performance-insights/willthornton.
10/09/2023, 1:11 PMSELECT namespace, object_id, relation, userset_namespace, userset_object_id, userset_relation, caveat_name, caveat_context FROM relation_tuple WHERE pg_visible_in_snapshot(created_xid, $1) = $2 AND pg_visible_in_snapshot(deleted_xid, $3) = $4 AND ((userset_namespace = $5 AND userset_object_id IN (<LIST OF OBJECT_IDS>))) AND namespace = $30 AND relation = $31 ORDER BY userset_namespace, userset_object_id, userset_relation, namespace, object_id, relation LIMIT $32
These take on order of `183±300`ms to complete, with the worst we've seen taking 3000ms
vroldanbet
10/09/2023, 1:32 PMwillthornton.
10/09/2023, 2:50 PMix_relation_by_deleted_xid
, ix_relation_tuple_by_subject
and ix_relation_tuple_by_subject_relation
willthornton.
10/09/2023, 2:59 PMvroldanbet
10/09/2023, 3:23 PMlimit
parameter in the LookupResources
call, which defines the size of the page to returnvroldanbet
10/09/2023, 3:25 PMEXPLAIN
in RDS for that specific query that's being slow for youwillthornton.
10/09/2023, 3:44 PMwillthornton.
10/09/2023, 3:46 PMuserset_namespace
, userset_object_id
, namespace
and relation
help here?yetitwo
10/09/2023, 4:01 PMwillthornton.
10/09/2023, 4:02 PMwillthornton.
10/09/2023, 4:03 PMvroldanbet
10/09/2023, 5:17 PMwillthornton.
10/09/2023, 5:20 PMwillthornton.
10/09/2023, 5:20 PMvroldanbet
10/09/2023, 5:24 PMJoey
10/09/2023, 5:31 PMJoey
10/09/2023, 5:31 PMwillthornton.
10/09/2023, 8:39 PMwillthornton.
10/09/2023, 8:40 PMwillthornton.
10/09/2023, 8:42 PMJoey
10/09/2023, 8:48 PMJoey
10/09/2023, 8:49 PMwillthornton.
10/09/2023, 10:13 PMwillthornton.
10/10/2023, 11:19 AMwillthornton.
10/10/2023, 11:20 AMwillthornton.
10/10/2023, 11:21 AMwillthornton.
10/10/2023, 11:21 AMwillthornton.
10/10/2023, 1:28 PM9223372036854775807
willthornton.
10/10/2023, 1:29 PMyetitwo
10/10/2023, 1:44 PMwillthornton.
10/10/2023, 1:50 PMwillthornton.
10/10/2023, 1:50 PMyetitwo
10/10/2023, 2:21 PMvroldanbet
10/10/2023, 4:00 PMIN
clause there, so the limit is implicit to the number of elements there, which I believe is controlled by the applicationJoey
10/10/2023, 5:14 PMJoey
10/10/2023, 5:14 PMwillthornton.
10/10/2023, 6:18 PMvroldanbet
10/10/2023, 6:37 PMEXPLAIN (ANALYZE, VERBOSE, BUFFERS)
to have more data around the queryvroldanbet
10/10/2023, 6:38 PMvroldanbet
10/10/2023, 6:38 PM