Joakim Lodén
05/20/2025, 12:37 PMWriteRelationships
. The UPDATE
SQL statement is surprisingly slow, postgres is creating a suboptimal plan, even after analyzing the table relation_tuple
.
Example deleting 3 relations: (see attachment)
Anyone else experiencing a similar problem?
I'm able to improve performance by creating extended statistics on table relation_tuple
, but should I? Are there any recommendations related to this?
Postgres: 15.3
SpiceDB: 1.43.0
https://cdn.discordapp.com/attachments/844600078948630559/1374365407774900285/explain_analyze_update.txt?ex=682dc907&is=682c7787&hm=8a8be1dfc43e2436ab78ca3cabe3a0b5abb0face8270eade40546bc98b15832c&vroldanbet
05/20/2025, 4:22 PMJoakim Lodén
05/21/2025, 7:08 AMvroldanbet
05/21/2025, 7:37 AMJoakim Lodén
05/21/2025, 9:04 AM2025-05-21 08:59:31.097 UTC [176] LOG: duration: 2.703 ms plan:
Query Text: UPDATE relation_tuple SET deleted_xid = $1 WHERE deleted_xid = $2 AND namespace = $3 AND object_id = $4 AND relation = $5 AND userset_namespace = $6 AND userset_object_id = $7
Update on relation_tuple (cost=0.56..8.77 rows=0 width=0) (actual time=2.701..2.701 rows=0 loops=1)
-> Index Scan using ix_relation_tuple_by_subject on relation_tuple (cost=0.56..8.77 rows=1 width=14) (actual time=0.040..2.530 rows=1 loops=1)
Index Cond: (((userset_object_id)::text = 'a76020d1-80d6-4d21-97fa-960b43c0efd3'::text) AND ((userset_namespace)::text = 'namespace2'::text) AND ((namespace)::text = 'namespace1'::text) AND ((relation)::text = 'relation1'::text))
Filter: ((deleted_xid = '9223372036854775807'::xid8) AND ((object_id)::text = '13b68f32-83c2-428a-b935-dc7e46d837db'::text))
Rows Removed by Filter: 994
Joakim Lodén
05/21/2025, 10:06 AMWriteRelationships
nor DeleteRelationships
uses hints in version 1.43.0. Maybe my observations are wrongJoakim Lodén
05/21/2025, 10:33 AMvroldanbet
05/21/2025, 1:08 PMJoakim Lodén
05/21/2025, 1:37 PMJoey
05/21/2025, 3:16 PMJoey
05/21/2025, 3:16 PMJoey
05/21/2025, 3:16 PMvroldanbet
05/21/2025, 3:52 PMJoey
05/21/2025, 3:57 PMJoakim Lodén
05/21/2025, 10:08 PM