SQL Server table-valued function executed code -


based on row level security have created table-valued function:

create function security.useraccesspredicate(@valueid int) returns table schemabinding return (     select 1 accessresult     @valueid =      (         select value          dbo.values          userid = cast(session_context(n'userid') nvarchar(50))     ) or nullif(cast(session_context(n'userid') nvarchar(50)),'') null );  create security policy security.usersecuritypolicy     add filter predicate security.useraccesspredicate(valueud) on dbo.maintable 

let's maintable contains milions of rows. useraccesspredicate calculating select value dbo.values every row independently? if ineffective guess. how check exact code generating when executing table-valued function? sql server profiler isn't way because using azure db.

i using sql server 2016 management studio.

best way @ execution plan policy turned off turned on. you'll see work doing consequence. you're adding table query similar doing join more efficient.

to answer question, if see addition of nested loop in plan when policy on, yes going row-by-row nested loops

also same dbcc show_statistics @ resource hits too. smaller tables never saw noticeable performance hits, < 100,000 rows in similar implementation.

i found link useful when getting before.

https://www.mssqltips.com/sqlservertip/4005/sql-server-2016-row-level-security-limitations-performance-and-troubleshooting/


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -