Weird behaviour with row level security policy

  • Hi guys,

    I am trying to figure out what is wrong with this implementation. I have a table called "POSTS" with 32 thousands rows inserted.

    This table has a column called "OWNER" which indicates the company of the user who inserted that post.

    I've created a security row policy which evaluates the rows and returns only the rows of the current logged user's company.

    The security level function I created is structured as follow

    CREATE FUNCTION [RLS].[fn_SecureOwnerData](@ownerId AS int)

    RETURNS TABLE

    with SCHEMABINDING

    AS

    RETURN SELECT 1 AS 'secured_row'

    WHERE (@ownerId = (SELECT TOP 1 owner FROM dbo.users where users.username = CURRENT_USER));

    The problem is that if the current user has an user name which ends with the letter "Z" every query made on the table "posts" hangs for about 3 minutes. If the user name does not end with a "Z" the query works perfectly.

    I don't know what to say, what can it be?

    Thanks

  • I have no idea. Can you repro in another db and share some DDL?

  • This was removed by the editor as SPAM

Viewing 3 posts - 1 through 2 (of 2 total)

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