I am using RLS in power bi embedded on a database using directquery which seems to be extremely slow.
We have tracked this down to the underlying dynamic SQL that is generated, it is using the COALESCE function.
(COALESCE([t4].[projectID], 0) = 49)
When I execute the SQL in query analyzer as expected the query is very slow, however when I modify the line with coalesce to:
([t4].[projectID] = 49)
the query executes within seconds.
Why is this the case? Obviously I have very little way of influencing the dynamic SQL that is generated.