authzed / spicedb

Open Source, Google Zanzibar-inspired permissions database to enable fine-grained authorization for customer applications
https://authzed.com/docs
Apache License 2.0
4.72k stars 251 forks source link

LookupResources Postgres query optimization #1850

Closed alecmerdler closed 3 months ago

alecmerdler commented 3 months ago

Fixes potential slow reverse lookup queries when using Postgres by changing the order of the columns being compared in the cursor. By comparing the numerical IDs before the string relations, the query is able to short-circuit sooner and return faster.