|
|
|
|
|
by kiwicopple
1124 days ago
|
|
With PostgREST you can use the pre-fetch method to solve this: https://postgrest.org/en/stable/references/transactions.html... You can use that to inject your ACL/permissions into a setting - set_config('permissions', '{"allowed":true}'). Then in your RLS rules you can pluck them out - current_setting('permissions'::jsonb). This should make your RLS faster than most other options, in theory, because of data co-location |
|
[1]: Both numbers from our own testing, where the 7 seconds is the best we've been able to make it by using a SECURITY DEFINER function in a `this_thing_id IN (SELECT allowed_thing_ids())` style, which should have basically the same result in performance terms as separately doing the lookup with pre-fetching, because it's still checking the IN clause for 1,000,000 rows before doing anything else.