Skip to content

Is it more efficient to include "where" condition in query with RLS? #791

Answered by steve-chavez
tawjaw asked this question in Questions
Discussion options

You must be logged in to vote

Hey @tawja,

You can always check the postgres planning/execution time with EXPLAIN ANALYZE on the SQL Editor.

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.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@tawjaw
Comment options

@steve-chavez
Comment options

@tawjaw
Comment options

Answer selected by tawjaw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants