Is it more efficient to include "where" condition in query with RLS? #791
-
Hello, If I have a policy on select for a table this supabase.from('table_name').select('*') and this supabase.from('table_name').select('*').eq('user_id', user_id) should return the same rows. But is including the equal condition makes the query more efficient in any way? |
Beta Was this translation helpful? Give feedback.
Answered by
steve-chavez
Mar 2, 2021
Replies: 1 comment 3 replies
-
Hey @tawja, You can always check the postgres planning/execution time with explain analyze select * from table_name where user_id = <val>;
-- Planning Time: 0.312 ms
-- Execution Time: 0.116 ms For your question, RLS acts like an implicit where, so you'd be essentially doing: select * from table_name where user_id = auth.uid() and user_id = <val>; Which should give you more or less the same performance. |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
tawjaw
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @tawja,
You can always check the postgres planning/execution time with
EXPLAIN ANALYZE
on the SQL Editor.For your question, RLS acts like an implicit where, so you'd be essentially doing:
Which should give you more or less the same performance.