0

I have implemented Row Level Security using on SQL Server 2016. I think I have a failry complex setup, but our security requirement is complex.

This is in the context of a data warehouse. I have basic fact and dimension tables. I applied row level security to one of my dimension table with the following setup:

Table 1 : dimDataSources (standard physical table)
Table 2 : dimDataSources_Secured (Memory Optimized table)

I created a Security Policy on the dimDataSources_Secured (In-Memory) that uses a Natively Compiled function. That function read another Memory Optimized table that contains lookup values and Active Directory Groups that can read the record. The function use the is_member() function to return 1 for all records that are allowed for my groups.

So the context seems a bit complex but so far it works. But... now I get to use this in jonctions with fact table and we get performance hit. Here, I am not applying row level security directly on the fact table... only on the dimension table.

So my problem is if I run this:

SELECT SUM(Sales) FROM factSales

It returns quickly, let's say 2 seconds.

If I run the same query but with a join on the secured table (or view), it will take 5-6 times longer:

SELECT SUM(Sales) FROM factSales f
INNER JOIN dimDataSources_Secured d ON f.DataSourceKey = d.DataSourceKey

This retrieves only the source I have access to based on my AD groups. When the execution plan changes, it seems like it retrieves the fact table data quickly, but then will do a nested loop lookup on the In-Memory table to get the allowed records.

Is that behavior caused by the usage of the Filter Predicate functions? Anyone had good or bad experiences using Row Level Security? Is it mature enough to put in production? Is it a good candidate for data warehousing (i.e. processing big volumes of data)?

It is hard to put more details on my actual function and queries without writing a novel. I'm mostly looking for guidelines or alternatives.

4

1 回答 1

1

该行为是由使用过滤谓词函数引起的吗?任何人在使用 Row Level Security 时都有过好的或坏的经历吗?是否成熟到可以投入生产?它是数据仓库(处理大量数据)的理想选择吗?

是的,您在使用 RLS 时会受到性能影响。Aaron Bertrand 在 2017 年 3 月写了一篇很好的文章Ben Snaidero在 2016 年写了一篇很好的文章。微软还提供了有关限制性能影响的模式的指导。

我从未见过为 OLAP 模式实现 RLS,所以我无法对此发表评论。没有看到您的过滤谓词,很难说,但这通常是魔鬼所在。

于 2018-07-26T21:05:38.527 回答