RLS Causing RBAR

  • Hi all,

    First I want to ask just a generic question.  Does RLS in SQL always cause a Row by Row execution?   So we have a view that its implemented on that has 1.7million records and when i look a the query plan on the Index Scan its 1.7m executions returning one row at a time.  Rows per execution = 1.  That really doesn't sound like it should be correct.

    So firstly I am just trying to find out if this is normal (I hope not).

    Secondly, if that is wrong, could the implementation using IS_ROLEMEMBER cause this?

    Also on a side note.  I have seen some people use the PK of the table being passed into the RLS function but others dont.  Is that a no go - or does that not really matter?

    Many thanks

    Dan

  • This was removed by the editor as SPAM

  • It's called ROW level security for a reason !

    So RLS introduces additional processing overhead as the database engine needs to evaluate security predicates for each row.

    Of course this requirement also goes with joins.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • But I can put the same security (using Is_member) in a view and the Executions is 1 and the Rows per execution = 1.7m.

    So my question then is - why does row level security require (from what I understand from what you are saying) a non set based operation when the same can be achieved by a set based operation within a view?

    Sorry if I have misunderstood you at all.  Its been a while since I looked at query plans and RLS is a little new for me.

  • because it has to validate each and every row of the RLS object before it is to be processed by your query

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Do you have an access predicate table valued function for the rls? If so could you paste it in here?

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply